From f3ec4a5208febeeca53a145861807a2dc43dac7f Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Fri, 19 Jan 2018 23:30:17 -0600 Subject: [PATCH] Split up xpack plugins into their own modules (elastic/x-pack-elasticsearch#3643) Thanks to some great work by a bunch of amazing people, the chuck norris xpack split is a go! Original commit: elastic/x-pack-elasticsearch@dad98e28f4043f805907af2ad441908f64ca6c70 --- build.gradle | 10 +- dev-tools/checkstyle_suppressions.xml | 34 +- docs/build.gradle | 3 +- license-tools/build.gradle | 2 +- plugin/bin/x-pack/x-pack-env | 7 - plugin/bin/x-pack/x-pack-env.bat | 5 - plugin/build.gradle | 298 ++-------- plugin/core/build.gradle | 290 ++++++++- .../licenses/bcpkix-jdk15on-1.58.jar.sha1 | 0 .../licenses/bcprov-jdk15on-1.58.jar.sha1 | 0 .../licenses/bouncycastle-LICENSE.txt | 0 .../licenses/bouncycastle-NOTICE.txt | 0 plugin/core/licenses/commons-LICENSE.txt | 202 +++++++ plugin/core/licenses/commons-NOTICE.txt | 17 + .../core/licenses/commons-codec-1.10.jar.sha1 | 1 + .../licenses/commons-logging-1.1.3.jar.sha1 | 1 + .../licenses/httpasyncclient-4.1.2.jar.sha1 | 1 + .../core/licenses/httpclient-4.5.2.jar.sha1 | 1 + plugin/core/licenses/httpclient-LICENSE.txt | 558 ++++++++++++++++++ plugin/core/licenses/httpclient-NOTICE.txt | 6 + plugin/core/licenses/httpcore-4.4.5.jar.sha1 | 1 + .../licenses/unboundid-ldapsdk-3.2.0.jar.sha1 | 0 .../licenses/unboundid-ldapsdk-LICENSE.txt | 0 .../licenses/unboundid-ldapsdk-NOTICE.txt | 0 .../x-pack => core/src/main/bin}/extension | 0 .../src/main/bin}/extension.bat | 0 plugin/core/src/main/bin/x-pack-env | 12 + plugin/core/src/main/bin/x-pack-env.bat | 10 + .../src/main/config}/log4j2.properties | 0 .../common/network/InetAddressHelper.java | 0 .../org/elasticsearch/license/CryptUtils.java | 0 .../license/ExpirationCallback.java | 0 .../elasticsearch/license/LicenseService.java | 0 .../elasticsearch/license/LicenseUtils.java | 0 .../license/LicenseVerifier.java | 0 .../license/LicensesMetaData.java | 4 +- .../org/elasticsearch/license/Licensing.java | 7 + .../license/LicensingClient.java | 0 .../license/RestDeleteLicenseAction.java | 0 .../license/RestGetLicenseAction.java | 0 .../license/RestGetTrialStatus.java | 0 .../license/RestPostStartTrialLicense.java | 0 .../license/RestPutLicenseAction.java | 0 .../license/SelfGeneratedLicense.java | 0 .../license/TransportDeleteLicenseAction.java | 0 .../license/TransportGetLicenseAction.java | 0 .../TransportGetTrialStatusAction.java | 0 .../TransportPostStartTrialAction.java | 0 .../license/TransportPutLicenseAction.java | 0 .../license/XPackLicenseState.java | 30 +- .../elasticsearch/license/package-info.java | 0 .../xpack/EmptyXPackFeatureSet.java | 43 ++ .../org/elasticsearch/xpack/XPackClient.java | 0 .../xpack/XPackClientPlugin.java | 384 ++++++++++++ .../{XpackField.java => XPackField.java} | 6 +- .../org/elasticsearch/xpack/XPackPlugin.java | 238 ++++++++ .../elasticsearch/xpack/XPackSettings.java | 11 +- .../action/TransportXPackInfoAction.java | 1 + .../action/TransportXPackUsageAction.java | 0 .../xpack/common/IteratingActionListener.java | 0 .../xpack/common/socket/SocketAccess.java | 0 .../deprecation/DeprecationInfoAction.java | 4 +- .../InstallXPackExtensionCommand.java | 0 .../extensions/ListXPackExtensionCommand.java | 0 .../RemoveXPackExtensionCommand.java | 5 +- .../xpack/extensions/XPackExtension.java | 0 .../xpack/extensions/XPackExtensionCli.java | 0 .../xpack/extensions/XPackExtensionInfo.java | 0 .../extensions/XPackExtensionPolicy.java | 0 .../extensions/XPackExtensionSecurity.java | 0 .../extensions/XPackExtensionsService.java | 0 .../xpack/graph/GraphFeatureSetUsage.java | 23 + .../graph/action/GraphExploreResponse.java | 6 +- .../elasticsearch/xpack/graph/action/Hop.java | 6 +- .../xpack/graph/action/Vertex.java | 2 +- .../xpack/graph/action/VertexRequest.java | 6 +- .../ml/MachineLearningClientActionPlugin.java | 5 - .../ml/MachineLearningFeatureSetUsage.java | 61 ++ .../xpack/ml/MachineLearningField.java | 22 + .../xpack/ml/action/CloseJobAction.java | 12 +- .../xpack/ml/action/DeleteCalendarAction.java | 4 +- .../ml/action/DeleteCalendarEventAction.java | 2 +- .../xpack/ml/action/DeleteDatafeedAction.java | 6 +- .../ml/action/DeleteExpiredDataAction.java | 2 +- .../xpack/ml/action/DeleteFilterAction.java | 4 +- .../xpack/ml/action/DeleteJobAction.java | 4 +- .../ml/action/DeleteModelSnapshotAction.java | 4 +- .../ml/action/FinalizeJobExecutionAction.java | 6 +- .../xpack/ml/action/FlushJobAction.java | 4 +- .../xpack/ml/action/ForecastJobAction.java | 6 +- .../xpack/ml/action/GetBucketsAction.java | 6 +- .../ml/action/GetCalendarEventsAction.java | 4 +- .../xpack/ml/action/GetCalendarsAction.java | 2 +- .../xpack/ml/action/GetCategoriesAction.java | 4 +- .../xpack/ml/action/GetDatafeedsAction.java | 4 +- .../ml/action/GetDatafeedsStatsAction.java | 6 +- .../xpack/ml/action/GetFiltersAction.java | 2 +- .../xpack/ml/action/GetInfluencersAction.java | 6 +- .../xpack/ml/action/GetJobsAction.java | 4 +- .../xpack/ml/action/GetJobsStatsAction.java | 6 +- .../ml/action/GetModelSnapshotsAction.java | 4 +- .../ml/action/GetOverallBucketsAction.java | 6 +- .../xpack/ml/action/GetRecordsAction.java | 6 +- .../ml/action/IsolateDatafeedAction.java | 6 +- .../xpack/ml/action/KillProcessAction.java | 8 +- .../xpack/ml/action/OpenJobAction.java | 6 +- .../ml/action/PostCalendarEventsAction.java | 4 +- .../xpack/ml/action/PostDataAction.java | 6 +- .../ml/action/PreviewDatafeedAction.java | 6 +- .../xpack/ml/action/PutCalendarAction.java | 4 +- .../xpack/ml/action/PutDatafeedAction.java | 4 +- .../xpack/ml/action/PutFilterAction.java | 2 +- .../xpack/ml/action/PutJobAction.java | 4 +- .../ml/action/RevertModelSnapshotAction.java | 4 +- .../xpack/ml/action/StartDatafeedAction.java | 2 +- .../xpack/ml/action/StopDatafeedAction.java | 8 +- .../ml/action/UpdateCalendarJobAction.java | 2 +- .../xpack/ml/action/UpdateDatafeedAction.java | 2 +- .../xpack/ml/action/UpdateJobAction.java | 2 +- .../ml/action/UpdateModelSnapshotAction.java | 4 +- .../xpack/ml/action/UpdateProcessAction.java | 4 +- .../ml/action/ValidateDetectorAction.java | 2 +- .../ml/action/ValidateJobConfigAction.java | 2 +- .../ml/client/MachineLearningClient.java | 0 .../xpack/ml/job/messages/Messages.java | 4 +- .../xpack/ml/notifications/AuditorField.java | 13 + .../monitoring/MonitoringFeatureSetUsage.java | 48 ++ .../action/MonitoringBulkResponse.java | 4 +- .../monitoring/client/MonitoringClient.java | 0 .../xpack/rest/XPackRestHandler.java | 0 .../rest/action/RestXPackInfoAction.java | 0 .../rest/action/RestXPackUsageAction.java | 0 .../xpack/scheduler/SchedulerEngine.java | 0 .../xpack/security/ScrollHelper.java | 0 .../xpack/security/SecurityContext.java | 8 +- .../xpack/security/SecurityExtension.java | 26 - .../security/SecurityFeatureSetUsage.java | 95 +++ .../xpack/security/SecurityField.java | 11 +- .../SecurityLifecycleServiceField.java | 12 + .../xpack/security/SecuritySettings.java | 52 ++ .../xpack/security/UserSettings.java | 48 ++ .../action/realm/ClearRealmCacheRequest.java | 8 +- .../action/realm/ClearRealmCacheResponse.java | 4 +- .../action/role/ClearRolesCacheRequest.java | 4 +- .../action/role/ClearRolesCacheResponse.java | 4 +- .../security/action/role/PutRoleRequest.java | 2 +- .../DeleteRoleMappingResponse.java | 4 +- .../action/token/CreateTokenRequest.java | 2 +- .../action/token/InvalidateTokenRequest.java | 6 +- .../action/token/InvalidateTokenResponse.java | 4 +- .../audit/index/IndexAuditTrailField.java | 12 + .../xpack/security/authc/Authentication.java | 4 +- .../authc/AuthenticationFailureHandler.java | 0 .../security/authc/AuthenticationResult.java | 0 .../security/authc/AuthenticationToken.java | 0 .../DefaultAuthenticationFailureHandler.java | 0 .../authc/InternalRealmsSettings.java | 36 ++ .../xpack/security/authc/KeyAndTimestamp.java | 63 ++ .../xpack/security/authc/Realm.java | 4 +- .../xpack/security/authc/RealmConfig.java | 0 .../xpack/security/authc/RealmSettings.java | 6 +- .../xpack/security/authc/TokenMetaData.java | 17 +- .../authc/esnative/NativeRealmSettings.java | 24 + .../authc/file/FileRealmSettings.java | 24 + ...ActiveDirectorySessionFactorySettings.java | 43 ++ .../authc/ldap/LdapRealmSettings.java | 44 ++ .../ldap/LdapSessionFactorySettings.java | 28 + .../LdapUserSearchSessionFactorySettings.java | 44 ++ .../ldap/PoolingSessionFactorySettings.java | 39 ++ .../ldap/SearchGroupsResolverSettings.java | 39 ++ .../UserAttributeGroupsResolverSettings.java | 23 + .../support/LdapLoadBalancingSettings.java | 26 + .../support/LdapMetaDataResolverSettings.java | 23 + .../authc/ldap/support/LdapSearchScope.java | 0 .../ldap/support/SessionFactorySettings.java | 44 ++ .../security/authc/pki/PkiRealmSettings.java | 42 ++ .../CachingUsernamePasswordRealmSettings.java | 31 + .../authc/support/DnRoleMapperSettings.java | 25 + .../authc/support/UsernamePasswordToken.java | 38 +- .../mapper/CompositeRoleMapperSettings.java | 19 + .../support/mapper/ExpressionRoleMapping.java | 2 +- .../mapper/expressiondsl/AllExpression.java | 4 +- .../mapper/expressiondsl/AnyExpression.java | 4 +- .../expressiondsl/ExceptExpression.java | 4 +- .../expressiondsl/ExpressionParser.java | 7 - .../mapper/expressiondsl/FieldExpression.java | 4 +- .../authz/AuthorizationServiceField.java | 12 + .../authz/IndicesAndAliasesResolverField.java | 14 + .../accesscontrol/DocumentSubsetReader.java | 2 +- .../authz/accesscontrol/FieldExtractor.java | 0 .../accesscontrol/FieldSubsetReader.java | 0 .../accesscontrol/IndicesAccessControl.java | 4 +- .../authz/accesscontrol/OptOutQueryCache.java | 4 +- .../SetSecurityUserProcessor.java | 0 .../authz/permission/ClusterPermission.java | 0 .../authz/permission/FieldPermissions.java | 0 .../permission/FieldPermissionsCache.java | 0 .../FieldPermissionsDefinition.java | 0 .../authz/permission/IndicesPermission.java | 0 .../xpack/security/authz/permission/Role.java | 0 .../authz/permission/RunAsPermission.java | 0 .../authz/privilege/ClusterPrivilege.java | 0 .../privilege/HealthAndStatsPrivilege.java | 0 .../authz/privilege/IndexPrivilege.java | 0 .../security/authz/privilege/Privilege.java | 0 .../authz/privilege/SystemPrivilege.java | 0 .../authz/store/ClientReservedRoles.java | 44 -- .../security/authz/store/FileRolesStore.java | 6 +- .../authz/store/ReservedRolesStore.java | 133 +++++ .../xpack/security/client/SecurityClient.java | 0 .../security/rest/RestRequestFilter.java | 0 .../xpack/security/support/Exceptions.java | 6 +- .../xpack/security/support/NoOpLogger.java | 0 .../xpack/security/support/Validation.java | 4 +- .../transport/SSLExceptionHelper.java | 0 .../netty4/SecurityNetty4Transport.java | 14 +- .../xpack/security/user/BuiltinUserInfo.java | 0 .../xpack/security/user/ElasticUser.java | 0 .../user/InternalUserSerializationHelper.java | 0 .../xpack/security/user/KibanaUser.java | 0 .../security/user/LogstashSystemUser.java | 0 .../xpack/security/user/SystemUser.java | 0 .../security/user/XPackSecurityUser.java | 0 .../xpack/security/user/XPackUser.java | 5 +- .../elasticsearch/xpack/ssl/CertUtils.java | 0 .../xpack/ssl/CertificateGenerateTool.java | 0 .../xpack/ssl/CertificateTool.java | 0 .../ssl/CertificateTrustRestrictions.java | 0 .../xpack/ssl/DefaultJDKTrustConfig.java | 0 .../elasticsearch/xpack/ssl/KeyConfig.java | 0 .../elasticsearch/xpack/ssl/PEMKeyConfig.java | 0 .../xpack/ssl/PEMTrustConfig.java | 0 .../xpack/ssl/RestrictedTrustConfig.java | 0 .../xpack/ssl/RestrictedTrustManager.java | 0 .../xpack/ssl/SSLConfiguration.java | 0 .../xpack/ssl/SSLConfigurationReloader.java | 0 .../elasticsearch/xpack/ssl/SSLService.java | 0 .../xpack/ssl/StoreKeyConfig.java | 0 .../xpack/ssl/StoreTrustConfig.java | 0 .../xpack/ssl/TLSLicenseBootstrapCheck.java | 0 .../xpack/ssl/TrustAllConfig.java | 0 .../elasticsearch/xpack/ssl/TrustConfig.java | 0 .../TransportGetCertificateInfoAction.java | 0 .../rest/RestGetCertificateInfoAction.java | 0 .../upgrade/IndexUpgradeCheckVersion.java | 13 + .../xpack/upgrade/UpgradeField.java | 23 + .../actions/IndexUpgradeInfoAction.java | 2 +- .../xpack/watcher/WatcherFeatureSetUsage.java | 50 ++ .../xpack/watcher/client/WatcherClient.java | 0 .../execution/TriggeredWatchStoreField.java | 12 + .../execution/WatchExecutionContext.java | 8 +- .../watcher/history/HistoryStoreField.java | 25 + .../xpack/watcher/input/none/NoneInput.java | 2 +- .../WatcherIndexTemplateRegistryField.java | 25 + .../actions/get/GetWatchResponse.java | 2 +- .../actions/put/PutWatchResponse.java | 2 +- .../service/WatcherServiceRequest.java | 4 +- .../actions/stats/WatcherStatsResponse.java | 14 +- .../plugin-metadata/plugin-security.policy | 0 .../resources/logstash-index-template.json | 0 .../src/main/resources/monitoring-alerts.json | 0 .../src/main/resources/monitoring-beats.json | 0 .../src/main/resources/monitoring-es.json | 0 .../src/main/resources/monitoring-kibana.json | 0 .../main/resources/monitoring-logstash.json | 0 .../resources/security-index-template.json | 0 .../main/resources/security_audit_log.json | 0 .../src/main/resources/triggered-watches.json | 0 .../src/main/resources/watch-history.json | 0 .../src/main/resources/watches.json | 0 .../xpack/security/crypto/migrate.help | 0 .../security/crypto/tool/syskey-generate.help | 0 .../action/MockIndicesRequest.java | 0 .../stats/IndicesStatsResponseTestUtils.java | 0 .../http/netty4/Netty4HttpMockUtil.java | 0 .../AbstractLicenseServiceTestCase.java | 0 .../AbstractLicensesIntegrationTestCase.java | 26 +- .../license/ExpirationCallbackTests.java | 0 .../license/LicenseClusterChangeTests.java | 0 .../license/LicenseOperationModeTests.java | 0 .../LicenseOperationModeUpdateTests.java | 0 .../license/LicenseRegistrationTests.java | 0 .../license/LicenseScheduleTests.java | 0 .../license/LicenseSerializationTests.java | 0 ...icenseServiceClusterNotRecoveredTests.java | 4 +- .../license/LicenseServiceClusterTests.java | 3 +- .../license/LicenseUtilsTests.java | 0 .../license/LicensesAcknowledgementTests.java | 0 .../license/LicensesManagerServiceTests.java | 8 +- .../LicensesMetaDataSerializationTests.java | 0 .../license/LicensesTransportTests.java | 12 +- .../OperationModeFileWatcherTests.java | 0 .../license/PutLicenseResponseTests.java | 0 .../license/SelfGeneratedLicenseTests.java | 0 .../org/elasticsearch/license/TestUtils.java | 0 .../license/UpgradeToTrialTests.java | 7 +- .../script/MockMustacheScriptEngine.java | 3 +- .../test/SecuritySettingsSourceField.java | 15 + .../org/elasticsearch/test/TestMatchers.java | 0 .../org/elasticsearch/test/http/Headers.java | 0 .../elasticsearch/test/http/MockRequest.java | 0 .../elasticsearch/test/http/MockResponse.java | 0 .../test/http/MockWebServer.java | 0 .../xpack/ClientHelperTests.java | 0 .../xpack/LocalStateCompositeXPackPlugin.java | 385 ++++++++++++ .../xpack/TestXPackTransportClient.java | 2 +- .../xpack/XPackSettingsTests.java | 0 .../xpack/XPackSingleNodeTestCase.java | 8 +- .../action/TransportXPackInfoActionTests.java | 0 .../common/IteratingActionListenerTests.java | 0 .../deprecation/DeprecationChecksTests.java | 0 .../DeprecationInfoActionRequestTests.java | 0 .../DeprecationInfoActionResponseTests.java | 0 .../deprecation/DeprecationIssueTests.java | 0 .../InstallXPackExtensionCommandTests.java | 5 +- .../ListXPackExtensionCommandTests.java | 2 +- .../RemoveXPackExtensionCommandTests.java | 2 +- .../extensions/XPackExtensionInfoTests.java | 0 .../XPackExtensionSecurityTests.java | 0 .../extensions/XPackExtensionTestUtil.java | 0 .../XPackExtensionsServiceTests.java | 0 .../integration/MlRestTestStateCleaner.java | 0 .../test/MockPainlessScriptEngine.java | 0 .../CancelPersistentTaskRequestTests.java | 0 .../PersistentTasksClusterServiceTests.java | 0 .../PersistentTasksCustomMetaDataTests.java | 0 .../PersistentTasksExecutorFullRestartIT.java | 0 .../persistent/PersistentTasksExecutorIT.java | 0 .../PersistentTasksExecutorResponseTests.java | 0 ...PersistentTasksNodeServiceStatusTests.java | 0 .../PersistentTasksNodeServiceTests.java | 0 .../RestartPersistentTaskRequestTests.java | 0 .../StartPersistentActionRequestTests.java | 0 .../persistent/TestPersistentTasksPlugin.java | 0 .../UpdatePersistentTaskRequestTests.java | 0 .../security/test/SecurityAssertions.java | 4 +- .../xpack/ssl/CertUtilsTests.java | 0 .../xpack/ssl/RestrictedTrustConfigTests.java | 0 .../ssl/RestrictedTrustManagerTests.java | 0 .../ssl/SSLConfigurationReloaderTests.java | 0 .../ssl/SSLConfigurationSettingsTests.java | 0 .../xpack/ssl/SSLConfigurationTests.java | 0 .../xpack/ssl/SSLServiceTests.java | 0 .../xpack/ssl/StoreKeyConfigTests.java | 0 .../ssl/TLSLicenseBootstrapCheckTests.java | 0 .../xpack/ssl/TestsSSLService.java | 0 .../xpack/ssl/cert/CertificateInfoTests.java | 0 .../xpack/template/TemplateUtilsTests.java | 0 .../xpack/test/rest/XPackRestTestHelper.java | 4 +- .../xpack/watcher/watch/clock/ClockMock.java | 0 .../src/test/resources/monitoring-test.json | 0 .../complex-x-pack-extension-security.policy | 0 .../simple-x-pack-extension-security.policy | 0 ...nresolved-x-pack-extension-security.policy | 0 .../ssl/certs/simple/README.asciidoc | 0 .../ssl/certs/simple/active-directory-ca.crt | 0 .../transport/ssl/certs/simple/openldap.crt | 0 .../transport/ssl/certs/simple/openldap.der | Bin .../ssl/certs/simple/openssl_config.cnf | 0 .../ssl/certs/simple/prime256v1-cert.pem | 0 .../certs/simple/prime256v1-key-noparam.pem | 0 .../ssl/certs/simple/prime256v1-key.pem | 0 .../simple/testclient-client-profile.crt | 0 .../simple/testclient-client-profile.jks | Bin .../simple/testclient-client-profile.p12 | Bin .../simple/testclient-client-profile.pem | 0 .../transport/ssl/certs/simple/testclient.crt | 0 .../transport/ssl/certs/simple/testclient.jks | Bin .../transport/ssl/certs/simple/testclient.p12 | Bin .../transport/ssl/certs/simple/testclient.pem | 0 .../certs/simple/testnode-client-profile.crt | 0 .../certs/simple/testnode-client-profile.jks | Bin .../certs/simple/testnode-client-profile.p12 | Bin .../certs/simple/testnode-client-profile.pem | 0 .../simple/testnode-different-passwords.jks | Bin .../ssl/certs/simple/testnode-ip-only.crt | 0 .../ssl/certs/simple/testnode-ip-only.jks | Bin .../certs/simple/testnode-no-subjaltname.cert | 0 .../certs/simple/testnode-no-subjaltname.jks | Bin .../transport/ssl/certs/simple/testnode.crt | 0 .../transport/ssl/certs/simple/testnode.jks | Bin .../transport/ssl/certs/simple/testnode.p12 | Bin .../transport/ssl/certs/simple/testnode.pem | 0 .../certs/simple/truststore-testnode-only.jks | Bin .../{ => core}/src/test/resources/private.key | Bin .../{ => core}/src/test/resources/public.key | 0 plugin/deprecation/build.gradle | 31 + .../xpack/deprecation/Deprecation.java | 4 +- .../xpack/deprecation/DeprecationChecks.java | 0 .../deprecation/IndexDeprecationChecks.java | 0 .../RestDeprecationInfoAction.java | 0 .../TransportDeprecationInfoAction.java | 4 +- .../plugin-metadata/plugin-security.policy | 50 ++ .../IndexDeprecationChecksTests.java | 0 plugin/graph/build.gradle | 23 +- .../org/elasticsearch/xpack/graph/Graph.java | 20 +- .../xpack/graph/GraphFeatureSet.java | 18 +- .../action/TransportGraphExploreAction.java | 4 +- .../graph/rest/action/RestGraphAction.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../xpack/graph/GraphFeatureSetTests.java | 4 +- .../xpack/graph/test/GraphTests.java | 14 +- plugin/logstash/build.gradle | 33 ++ .../xpack/logstash/Logstash.java | 7 +- .../xpack/logstash/LogstashFeatureSet.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../logstash/LogstashFeatureSetTests.java | 0 plugin/ml-cpp-snapshot/build.gradle | 2 +- plugin/ml/build.gradle | 41 +- .../xpack/ml/InvalidLicenseEnforcer.java | 0 .../xpack/ml/MachineLearning.java | 161 +++-- .../xpack/ml/MachineLearningFeatureSet.java | 269 +++++++++ .../xpack/ml/MlAssignmentNotifier.java | 0 .../xpack/ml/MlDailyMaintenanceService.java | 0 .../xpack/ml/MlInitializationService.java | 0 .../xpack/ml/MlLifeCycleService.java | 0 .../ml/action/TransportCloseJobAction.java | 0 .../action/TransportDeleteCalendarAction.java | 0 .../TransportDeleteCalendarEventAction.java | 0 .../action/TransportDeleteDatafeedAction.java | 0 .../TransportDeleteExpiredDataAction.java | 0 .../action/TransportDeleteFilterAction.java | 0 .../ml/action/TransportDeleteJobAction.java | 4 +- .../TransportDeleteModelSnapshotAction.java | 0 .../TransportFinalizeJobExecutionAction.java | 0 .../ml/action/TransportFlushJobAction.java | 0 .../ml/action/TransportForecastJobAction.java | 0 .../ml/action/TransportGetBucketsAction.java | 0 .../TransportGetCalendarEventsAction.java | 0 .../action/TransportGetCalendarsAction.java | 0 .../action/TransportGetCategoriesAction.java | 0 .../action/TransportGetDatafeedsAction.java | 0 .../TransportGetDatafeedsStatsAction.java | 0 .../ml/action/TransportGetFiltersAction.java | 0 .../action/TransportGetInfluencersAction.java | 0 .../ml/action/TransportGetJobsAction.java | 0 .../action/TransportGetJobsStatsAction.java | 0 .../TransportGetModelSnapshotsAction.java | 0 .../TransportGetOverallBucketsAction.java | 0 .../ml/action/TransportGetRecordsAction.java | 0 .../TransportIsolateDatafeedAction.java | 0 .../ml/action/TransportJobTaskAction.java | 0 .../ml/action/TransportKillProcessAction.java | 0 .../ml/action/TransportOpenJobAction.java | 4 +- .../TransportPostCalendarEventsAction.java | 0 .../ml/action/TransportPostDataAction.java | 0 .../TransportPreviewDatafeedAction.java | 0 .../ml/action/TransportPutCalendarAction.java | 0 .../ml/action/TransportPutDatafeedAction.java | 5 +- .../ml/action/TransportPutFilterAction.java | 0 .../ml/action/TransportPutJobAction.java | 5 +- .../TransportRevertModelSnapshotAction.java | 0 .../action/TransportStartDatafeedAction.java | 4 +- .../action/TransportStopDatafeedAction.java | 0 .../TransportUpdateCalendarJobAction.java | 0 .../action/TransportUpdateDatafeedAction.java | 0 .../ml/action/TransportUpdateJobAction.java | 0 .../TransportUpdateModelSnapshotAction.java | 0 .../action/TransportUpdateProcessAction.java | 0 .../TransportValidateDetectorAction.java | 0 .../TransportValidateJobConfigAction.java | 0 .../xpack/ml/datafeed/DatafeedJob.java | 0 .../xpack/ml/datafeed/DatafeedJobBuilder.java | 0 .../xpack/ml/datafeed/DatafeedManager.java | 0 .../ml/datafeed/DatafeedNodeSelector.java | 0 .../xpack/ml/datafeed/ProblemTracker.java | 0 .../extractor/DataExtractorFactory.java | 0 .../aggregation/AggregationDataExtractor.java | 0 .../AggregationDataExtractorContext.java | 0 .../AggregationDataExtractorFactory.java | 0 .../AggregationToJsonProcessor.java | 0 .../chunked/ChunkedDataExtractor.java | 0 .../chunked/ChunkedDataExtractorContext.java | 0 .../chunked/ChunkedDataExtractorFactory.java | 0 .../extractor/scroll/ExtractedField.java | 0 .../extractor/scroll/ExtractedFields.java | 0 .../extractor/scroll/ScrollDataExtractor.java | 0 .../scroll/ScrollDataExtractorContext.java | 0 .../scroll/ScrollDataExtractorFactory.java | 0 .../scroll/SearchHitToJsonProcessor.java | 0 .../xpack/ml/job/JobManager.java | 6 +- .../ml/job/UpdateJobProcessNotifier.java | 0 .../CategorizationAnalyzer.java | 0 .../categorization/MlClassicTokenizer.java | 0 .../MlClassicTokenizerFactory.java | 0 .../persistence/JobDataCountsPersister.java | 0 .../JobRenormalizedResultsPersister.java | 0 .../job/persistence/JobResultsPersister.java | 0 .../ml/job/persistence/StateStreamer.java | 0 .../OverallBucketsAggregator.java | 0 .../OverallBucketsCollector.java | 0 .../OverallBucketsProcessor.java | 0 .../OverallBucketsProvider.java | 0 .../ml/job/process/CountingInputStream.java | 0 .../ml/job/process/DataCountsReporter.java | 0 .../ml/job/process/DataStreamDiagnostics.java | 0 .../ml/job/process/NativeController.java | 0 .../job/process/NativeControllerHolder.java | 4 +- .../xpack/ml/job/process/ProcessCtrl.java | 0 .../xpack/ml/job/process/ProcessPipes.java | 0 .../process/autodetect/AutodetectBuilder.java | 0 .../autodetect/AutodetectCommunicator.java | 0 .../process/autodetect/AutodetectProcess.java | 0 .../autodetect/AutodetectProcessFactory.java | 0 .../autodetect/AutodetectProcessManager.java | 0 .../BlackHoleAutodetectProcess.java | 0 .../autodetect/NativeAutodetectProcess.java | 5 +- .../NativeAutodetectProcessFactory.java | 0 .../process/autodetect/ProcessContext.java | 4 +- .../job/process/autodetect/UpdateParams.java | 0 .../output/AutoDetectResultProcessor.java | 4 +- .../output/AutodetectResultsParser.java | 0 .../autodetect/output/FlushListener.java | 0 .../autodetect/output/StateProcessor.java | 0 .../autodetect/params/DataLoadParams.java | 0 .../autodetect/params/FlushJobParams.java | 0 .../autodetect/params/ForecastParams.java | 0 .../process/autodetect/params/TimeRange.java | 0 .../writer/AbstractDataToProcessWriter.java | 0 .../writer/AnalysisLimitsWriter.java | 0 .../writer/CannotParseTimestampException.java | 0 .../writer/ControlMsgToProcessWriter.java | 0 .../writer/CsvDataToProcessWriter.java | 0 .../autodetect/writer/CsvRecordWriter.java | 0 .../writer/DataToProcessWriter.java | 0 .../writer/DataToProcessWriterFactory.java | 0 .../writer/DateFormatDateTransformer.java | 0 .../autodetect/writer/DateTransformer.java | 0 .../writer/DoubleDateTransformer.java | 0 .../autodetect/writer/FieldConfigWriter.java | 0 .../writer/JsonDataToProcessWriter.java | 0 .../writer/LengthEncodedWriter.java | 0 .../autodetect/writer/MlFilterWriter.java | 0 .../writer/ModelPlotConfigWriter.java | 0 .../writer/ScheduledEventsWriter.java | 0 .../autodetect/writer/WriterConstants.java | 0 .../writer/XContentRecordReader.java | 0 .../ml/job/process/logging/CppLogMessage.java | 0 .../process/logging/CppLogMessageHandler.java | 0 .../normalizer/AbstractLeafNormalizable.java | 0 .../BucketInfluencerNormalizable.java | 0 .../normalizer/BucketNormalizable.java | 0 .../normalizer/InfluencerNormalizable.java | 0 .../ml/job/process/normalizer/Level.java | 0 .../MultiplyingNormalizerProcess.java | 0 .../normalizer/NativeNormalizerProcess.java | 0 .../NativeNormalizerProcessFactory.java | 0 .../job/process/normalizer/Normalizable.java | 0 .../ml/job/process/normalizer/Normalizer.java | 0 .../process/normalizer/NormalizerFactory.java | 0 .../process/normalizer/NormalizerProcess.java | 0 .../normalizer/NormalizerProcessFactory.java | 0 .../process/normalizer/NormalizerResult.java | 0 .../PartitionScoreNormalizable.java | 0 .../normalizer/RecordNormalizable.java | 0 .../job/process/normalizer/Renormalizer.java | 0 .../job/process/normalizer/ScoresUpdater.java | 0 .../ShortCircuitingRenormalizer.java | 0 .../output/NormalizerResultHandler.java | 0 .../ml/job/results/AutodetectResult.java | 0 .../AbstractExpiredJobDataRemover.java | 0 .../retention/ExpiredForecastsRemover.java | 0 .../ExpiredModelSnapshotsRemover.java | 0 .../job/retention/ExpiredResultsRemover.java | 0 .../xpack/ml/job/retention/MlDataRemover.java | 0 .../xpack/ml/notifications/Auditor.java | 3 +- .../ml/rest/RestDeleteExpiredDataAction.java | 0 .../calendar/RestDeleteCalendarAction.java | 0 .../RestDeleteCalendarEventAction.java | 0 .../calendar/RestDeleteCalendarJobAction.java | 0 .../calendar/RestGetCalendarEventsAction.java | 0 .../rest/calendar/RestGetCalendarsAction.java | 0 .../calendar/RestPostCalendarEventAction.java | 0 .../rest/calendar/RestPutCalendarAction.java | 0 .../calendar/RestPutCalendarJobAction.java | 0 .../datafeeds/RestDeleteDatafeedAction.java | 0 .../datafeeds/RestGetDatafeedStatsAction.java | 0 .../datafeeds/RestGetDatafeedsAction.java | 0 .../datafeeds/RestPreviewDatafeedAction.java | 0 .../rest/datafeeds/RestPutDatafeedAction.java | 0 .../datafeeds/RestStartDatafeedAction.java | 0 .../datafeeds/RestStopDatafeedAction.java | 0 .../datafeeds/RestUpdateDatafeedAction.java | 0 .../rest/filter/RestDeleteFilterAction.java | 0 .../ml/rest/filter/RestGetFiltersAction.java | 0 .../ml/rest/filter/RestPutFilterAction.java | 0 .../xpack/ml/rest/job/RestCloseJobAction.java | 0 .../ml/rest/job/RestDeleteJobAction.java | 0 .../xpack/ml/rest/job/RestFlushJobAction.java | 0 .../ml/rest/job/RestForecastJobAction.java | 0 .../ml/rest/job/RestGetJobStatsAction.java | 0 .../xpack/ml/rest/job/RestGetJobsAction.java | 0 .../xpack/ml/rest/job/RestOpenJobAction.java | 0 .../xpack/ml/rest/job/RestPostDataAction.java | 0 .../ml/rest/job/RestPostJobUpdateAction.java | 0 .../xpack/ml/rest/job/RestPutJobAction.java | 0 .../RestDeleteModelSnapshotAction.java | 0 .../RestGetModelSnapshotsAction.java | 0 .../RestRevertModelSnapshotAction.java | 0 .../RestUpdateModelSnapshotAction.java | 0 .../ml/rest/results/RestGetBucketsAction.java | 0 .../rest/results/RestGetCategoriesAction.java | 0 .../results/RestGetInfluencersAction.java | 0 .../results/RestGetOverallBucketsAction.java | 0 .../ml/rest/results/RestGetRecordsAction.java | 0 .../validate/RestValidateDetectorAction.java | 0 .../validate/RestValidateJobConfigAction.java | 0 .../xpack/ml/utils/DomainSplitFunction.java | 0 .../xpack/ml/utils/NamedPipeHelper.java | 0 .../xpack/ml/utils/StatsAccumulator.java | 0 .../ml/utils/VolatileCursorIterator.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../xpack/ml/transforms/exact.properties | 0 .../MachineLearningLicensingTests.java | 78 +-- .../xpack/ml/LocalStateMachineLearning.java | 67 +++ .../ml/MachineLearningFeatureSetTests.java | 12 +- .../xpack/ml/MachineLearningTests.java | 15 +- .../xpack/ml/MlAssignmentNotifierTests.java | 0 .../xpack/ml/MlClientHelperTests.java | 0 .../ml/MlDailyManagementServiceTests.java | 0 .../ml/MlInitializationServiceTests.java | 0 .../xpack/ml/MlMetadataTests.java | 0 .../ml/action/CloseJobActionRequestTests.java | 0 .../action/CloseJobActionResponseTests.java | 0 ...DeleteCalendarEventActionRequestTests.java | 0 .../ml/action/DeleteDatafeedRequestTests.java | 0 .../DeleteExpiredDataActionResponseTests.java | 0 .../xpack/ml/action/DeleteJobActionTests.java | 0 .../ml/action/DeleteJobRequestTests.java | 0 .../action/ForecastJobActionRequestTests.java | 0 .../ForecastJobActionResponseTests.java | 0 .../action/GetBucketActionRequestTests.java | 0 .../action/GetBucketActionResponseTests.java | 0 .../GetCalendarEventsActionRequestTests.java | 0 .../GetCalendarsActionRequestTests.java | 0 .../ml/action/GetCategoriesRequestTests.java | 0 .../ml/action/GetCategoriesResponseTests.java | 0 .../GetDatafeedStatsActionRequestTests.java | 0 .../GetDatafeedStatsActionResponseTests.java | 0 .../GetDatafeedsActionRequestTests.java | 0 .../GetDatafeedsActionResponseTests.java | 0 .../action/GetFiltersActionRequestTests.java | 0 .../action/GetFiltersActionResponseTests.java | 0 .../GetInfluencersActionRequestTests.java | 0 .../GetInfluencersActionResponseTests.java | 0 .../action/GetJobStatsActionRequestTests.java | 0 .../GetJobStatsActionResponseTests.java | 0 .../ml/action/GetJobsActionRequestTests.java | 0 .../ml/action/GetJobsActionResponseTests.java | 0 .../ml/action/GetJobsStatsActionTests.java | 0 .../GetModelSnapshotsActionRequestTests.java | 0 .../GetModelSnapshotsActionResponseTests.java | 0 .../GetOverallBucketsActionRequestTests.java | 0 .../GetOverallBucketsActionResponseTests.java | 0 .../action/GetRecordsActionRequestTests.java | 0 .../action/GetRecordsActionResponseTests.java | 0 .../ml/action/OpenJobActionRequestTests.java | 0 .../xpack/ml/action/OpenJobActionTests.java | 4 +- .../PostCalendarEventActionRequestTests.java | 0 .../ml/action/PostDataActionRequestTests.java | 0 .../action/PostDataActionResponseTests.java | 0 .../ml/action/PostDataFlushRequestTests.java | 0 .../ml/action/PostDataFlushResponseTests.java | 0 .../PreviewDatafeedActionRequestTests.java | 0 .../ml/action/PreviewDatafeedActionTests.java | 0 .../action/PutCalendarActionRequestTests.java | 0 .../PutCalendarActionResponseTests.java | 0 .../action/PutDatafeedActionRequestTests.java | 0 .../PutDatafeedActionResponseTests.java | 0 .../action/PutFilterActionRequestTests.java | 0 .../ml/action/PutJobActionRequestTests.java | 0 .../ml/action/PutJobActionResponseTests.java | 0 ...RevertModelSnapshotActionRequestTests.java | 0 ...evertModelSnapshotActionResponseTests.java | 0 .../StartDatafeedActionRequestTests.java | 0 .../ml/action/StartDatafeedActionTests.java | 0 .../StopDatafeedActionRequestTests.java | 0 .../UpdateCalendarJobActionResquestTests.java | 0 .../UpdateDatafeedActionRequestTests.java | 0 .../action/UpdateJobActionRequestTests.java | 0 ...UpdateModelSnapshotActionRequestTests.java | 0 ...pdateModelSnapshotActionResponseTests.java | 0 .../UpdateProcessActionRequestTests.java | 0 .../ValidateDetectorActionRequestTests.java | 0 .../ValidateJobConfigActionRequestTests.java | 0 .../xpack/ml/action/util/PageParamsTests.java | 0 .../xpack/ml/action/util/QueryPageTests.java | 0 .../xpack/ml/calendars/CalendarTests.java | 0 .../ml/calendars/ScheduledEventTests.java | 0 .../ml/datafeed/ChunkingConfigTests.java | 0 .../ml/datafeed/DatafeedConfigTests.java | 0 .../ml/datafeed/DatafeedJobBuilderTests.java | 0 .../xpack/ml/datafeed/DatafeedJobTests.java | 0 .../datafeed/DatafeedJobValidatorTests.java | 0 .../ml/datafeed/DatafeedManagerTests.java | 3 +- .../datafeed/DatafeedNodeSelectorTests.java | 0 .../xpack/ml/datafeed/DatafeedStateTests.java | 0 .../ml/datafeed/DatafeedUpdateTests.java | 0 .../ml/datafeed/ProblemTrackerTests.java | 0 .../extractor/DataExtractorFactoryTests.java | 0 .../extractor/ExtractorUtilsTests.java | 0 .../AggregationDataExtractorFactoryTests.java | 0 .../AggregationDataExtractorTests.java | 0 .../aggregation/AggregationTestUtils.java | 0 .../AggregationToJsonProcessorTests.java | 0 .../ChunkedDataExtractorFactoryTests.java | 0 .../chunked/ChunkedDataExtractorTests.java | 0 .../extractor/scroll/ExtractedFieldTests.java | 0 .../scroll/ExtractedFieldsTests.java | 0 .../scroll/ScrollDataExtractorTests.java | 0 .../scroll/SearchHitToJsonProcessorTests.java | 0 .../integration/AutodetectMemoryLimitIT.java | 0 .../AutodetectResultProcessorIT.java | 3 +- .../integration/BasicDistributedJobsIT.java | 0 .../integration/BasicRenormalizationIT.java | 0 .../ml/integration/CategorizationIT.java | 0 .../xpack/ml/integration/DatafeedJobsIT.java | 0 .../ml/integration/DatafeedJobsRestIT.java | 14 +- .../ml/integration/DeleteExpiredDataIT.java | 0 .../xpack/ml/integration/DeleteJobIT.java | 0 .../ml/integration/DetectionRulesIT.java | 0 .../ml/integration/EstablishedMemUsageIT.java | 0 .../xpack/ml/integration/ForecastIT.java | 0 ...erimResultsDeletedAfterReopeningJobIT.java | 0 .../xpack/ml/integration/JobProviderIT.java | 3 +- .../integration/JobStorageDeletionTaskIT.java | 0 .../integration/MlDistributedFailureIT.java | 0 .../xpack/ml/integration/MlJobIT.java | 4 +- .../MlNativeAutodetectIntegTestCase.java | 8 +- .../ml/integration/NetworkDisruptionIT.java | 0 .../ml/integration/OverallBucketsIT.java | 0 .../integration/RestoreModelSnapshotIT.java | 0 .../ml/integration/RevertModelSnapshotIT.java | 0 .../xpack/ml/integration/TooManyJobsIT.java | 0 .../integration/UpdateInterimResultsIT.java | 0 .../xpack/ml/job/JobManagerTests.java | 4 +- .../CategorizationAnalyzerTests.java | 5 +- .../MlClassicTokenizerTests.java | 0 .../ml/job/config/AnalysisConfigTests.java | 0 .../ml/job/config/AnalysisLimitsTests.java | 0 .../CategorizationAnalyzerConfigTests.java | 0 .../xpack/ml/job/config/ConditionTests.java | 0 .../xpack/ml/job/config/ConnectiveTests.java | 0 .../ml/job/config/DataDescriptionTests.java | 0 .../xpack/ml/job/config/DataFormatTests.java | 0 .../DefaultDetectorDescriptionTests.java | 0 .../ml/job/config/DetectionRuleTests.java | 0 .../xpack/ml/job/config/DetectorTests.java | 0 .../xpack/ml/job/config/JobBuilderTests.java | 0 .../xpack/ml/job/config/JobStateTests.java | 0 .../ml/job/config/JobTaskStatusTests.java | 0 .../xpack/ml/job/config/JobTests.java | 4 +- .../xpack/ml/job/config/JobUpdateTests.java | 0 .../xpack/ml/job/config/MlFilterTests.java | 0 .../ml/job/config/ModelPlotConfigTests.java | 0 .../xpack/ml/job/config/OperatorTests.java | 0 .../xpack/ml/job/config/RuleActionTests.java | 0 .../ml/job/config/RuleConditionTests.java | 0 .../ml/job/config/RuleConditionTypeTests.java | 0 .../ml/job/groups/GroupOrJobLookupTests.java | 0 .../xpack/ml/job/groups/GroupOrJobTests.java | 0 .../xpack/ml/job/messages/MessagesTests.java | 0 .../BatchedDocumentsIteratorTests.java | 0 .../ElasticsearchMappingsTests.java | 0 .../InfluencersQueryBuilderTests.java | 0 .../ml/job/persistence/JobProviderTests.java | 0 .../JobRenormalizedResultsPersisterTests.java | 0 .../persistence/JobResultsPersisterTests.java | 0 .../MockBatchedDocumentsIterator.java | 0 .../ml/job/persistence/MockClientBuilder.java | 0 .../ResultsFilterBuilderTests.java | 0 .../job/persistence/StateStreamerTests.java | 0 .../OverallBucketsAggregatorTests.java | 0 .../OverallBucketsCollectorTests.java | 0 .../OverallBucketsProviderTests.java | 0 .../job/process/CountingInputStreamTests.java | 0 .../job/process/DataCountsReporterTests.java | 0 .../process/DataStreamDiagnosticsTests.java | 0 .../job/process/DummyDataCountsReporter.java | 0 .../ml/job/process/NativeControllerTests.java | 0 .../ml/job/process/ProcessCtrlTests.java | 0 .../ml/job/process/ProcessPipesTests.java | 0 .../AutodetectCommunicatorTests.java | 0 .../AutodetectProcessManagerTests.java | 0 .../BlackHoleAutodetectProcessTests.java | 0 .../NativeAutodetectProcessTests.java | 0 .../AutoDetectResultProcessorTests.java | 0 .../output/AutodetectResultsParserTests.java | 0 .../output/FlushAcknowledgementTests.java | 0 .../autodetect/output/FlushListenerTests.java | 0 .../output/StateProcessorTests.java | 0 .../params/DataLoadParamsTests.java | 0 .../params/FlushJobParamsTests.java | 0 .../params/ForecastParamsTests.java | 0 .../autodetect/params/TimeRangeTests.java | 0 .../autodetect/state/DataCountsTests.java | 0 .../autodetect/state/MemoryStatusTests.java | 0 .../autodetect/state/ModelSizeStatsTests.java | 0 .../autodetect/state/ModelSnapshotTests.java | 0 .../autodetect/state/QuantilesTests.java | 0 .../AbstractDataToProcessWriterTests.java | 0 .../writer/AnalysisLimitsWriterTests.java | 0 .../ControlMsgToProcessWriterTests.java | 0 .../writer/CsvDataToProcessWriterTests.java | 0 .../autodetect/writer/CsvParserTests.java | 0 .../writer/CsvRecordWriterTests.java | 0 .../DataToProcessWriterFactoryTests.java | 0 .../DateFormatDateTransformerTests.java | 0 .../writer/DoubleDateTransformerTests.java | 0 .../writer/FieldConfigWriterTests.java | 0 .../writer/JsonDataToProcessWriterTests.java | 0 .../writer/LengthEncodedWriterTests.java | 0 .../writer/MlFilterWriterTests.java | 0 .../writer/ModelPlotConfigWriterTests.java | 0 .../writer/ScheduledEventsWriterTests.java | 0 .../writer/XContentRecordReaderTests.java | 0 .../logging/CppLogMessageHandlerTests.java | 0 .../process/logging/CppLogMessageTests.java | 0 .../BucketInfluencerNormalizableTests.java | 0 .../normalizer/BucketNormalizableTests.java | 0 .../InfluencerNormalizableTests.java | 0 .../normalizer/NormalizerResultTests.java | 0 .../process/normalizer/NormalizerTests.java | 0 .../normalizer/ScoresUpdaterTests.java | 0 .../ShortCircuitingRenormalizerTests.java | 0 .../output/NormalizerResultHandlerTests.java | 0 .../ml/job/results/AnomalyCauseTests.java | 0 .../ml/job/results/AnomalyRecordTests.java | 0 .../ml/job/results/AutodetectResultTests.java | 0 .../ml/job/results/BucketInfluencerTests.java | 0 .../xpack/ml/job/results/BucketTests.java | 0 .../job/results/CategoryDefinitionTests.java | 0 .../results/ForecastRequestStatsTests.java | 0 .../xpack/ml/job/results/ForecastTests.java | 0 .../xpack/ml/job/results/InfluenceTests.java | 0 .../xpack/ml/job/results/InfluencerTests.java | 0 .../xpack/ml/job/results/ModelPlotTests.java | 0 .../ml/job/results/OverallBucketTests.java | 0 .../ml/job/results/PartitionScoreTests.java | 0 .../job/results/ReservedFieldNamesTests.java | 0 .../ExpiredModelSnapshotsRemoverTests.java | 0 .../retention/ExpiredResultsRemoverTests.java | 0 .../GetModelSnapshotsTests.java | 0 .../UpdateModelSnapshotActionTests.java | 0 .../ml/notifications/AuditMessageTests.java | 0 .../xpack/ml/notifications/AuditorTests.java | 0 .../xpack/ml/notifications/LevelTests.java | 0 .../RestStartDatafeedActionTests.java | 0 .../xpack/ml/support/BaseMlIntegTestCase.java | 19 +- .../xpack/ml/test/SearchHitBuilder.java | 0 .../xpack/ml/utils/IntervalsTests.java | 0 .../xpack/ml/utils/MlStringsTests.java | 0 .../xpack/ml/utils/NameResolverTests.java | 0 .../xpack/ml/utils/NamedPipeHelperTests.java | 0 .../xpack/ml/utils/StatsAccumulatorTests.java | 0 ...eTimeFormatterTimestampConverterTests.java | 0 .../xpack/ml/utils/time/TimeUtilsTests.java | 0 plugin/monitoring/build.gradle | 45 +- .../xpack/monitoring/Monitoring.java | 60 +- .../monitoring/MonitoringFeatureSet.java | 40 +- .../xpack/monitoring/MonitoringService.java | 0 .../action/TransportMonitoringBulkAction.java | 0 .../monitoring/cleaner/CleanerService.java | 0 .../xpack/monitoring/collector/Collector.java | 5 +- .../cluster/ClusterStatsCollector.java | 0 .../cluster/ClusterStatsMonitoringDoc.java | 0 .../indices/IndexRecoveryCollector.java | 0 .../indices/IndexRecoveryMonitoringDoc.java | 0 .../indices/IndexStatsCollector.java | 0 .../indices/IndexStatsMonitoringDoc.java | 0 .../indices/IndicesStatsMonitoringDoc.java | 0 .../collector/ml/JobStatsCollector.java | 0 .../collector/ml/JobStatsMonitoringDoc.java | 0 .../collector/node/NodeStatsCollector.java | 0 .../node/NodeStatsMonitoringDoc.java | 0 .../collector/shards/ShardMonitoringDoc.java | 0 .../collector/shards/ShardsCollector.java | 0 .../exporter/BytesReferenceMonitoringDoc.java | 0 .../exporter/ClusterAlertsUtil.java | 0 .../xpack/monitoring/exporter/ExportBulk.java | 0 .../monitoring/exporter/ExportException.java | 0 .../xpack/monitoring/exporter/Exporter.java | 0 .../xpack/monitoring/exporter/Exporters.java | 0 .../exporter/FilteredMonitoringDoc.java | 0 .../http/ClusterAlertHttpResource.java | 0 .../exporter/http/HttpExportBulk.java | 0 .../http/HttpExportBulkResponseListener.java | 0 .../exporter/http/HttpExporter.java | 0 .../exporter/http/HttpHostBuilder.java | 0 .../exporter/http/HttpResource.java | 0 .../exporter/http/MultiHttpResource.java | 0 .../exporter/http/NodeFailureListener.java | 0 .../exporter/http/PipelineHttpResource.java | 0 .../http/PublishableHttpResource.java | 0 .../monitoring/exporter/http/Scheme.java | 0 .../SecurityHttpClientConfigCallback.java | 0 .../exporter/http/TemplateHttpResource.java | 0 .../http/TimeoutRequestConfigCallback.java | 0 .../exporter/http/VersionHttpResource.java | 0 .../http/WatcherExistsHttpResource.java | 0 .../monitoring/exporter/local/LocalBulk.java | 0 .../exporter/local/LocalExporter.java | 0 .../rest/MonitoringRestHandler.java | 0 .../rest/action/RestMonitoringBulkAction.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../watches/elasticsearch_cluster_status.json | 0 .../watches/elasticsearch_nodes.json | 0 .../elasticsearch_version_mismatch.json | 0 .../watches/kibana_version_mismatch.json | 0 .../watches/logstash_version_mismatch.json | 0 .../watches/xpack_license_expiration.json | 0 .../monitoring}/BaseCollectorTestCase.java | 22 +- .../monitoring/LocalStateMonitoring.java | 51 ++ .../monitoring/MonitoredSystemTests.java | 0 .../monitoring/MonitoringFeatureSetTests.java | 2 +- ...onitoringHistoryDurationSettingsTests.java | 0 .../MonitoringPluginClientTests.java | 8 +- .../monitoring/MonitoringServiceTests.java | 10 +- .../xpack/monitoring/MonitoringTestUtils.java | 0 .../monitoring/MultiNodesStatsTests.java | 5 + .../action/MonitoringBulkDocTests.java | 0 .../action/MonitoringBulkRequestTests.java | 0 .../action/MonitoringBulkResponseTests.java | 0 .../action/MonitoringIndexTests.java | 0 .../TransportMonitoringBulkActionTests.java | 0 .../AbstractIndicesCleanerTestCase.java | 4 + .../cleaner/CleanerServiceTests.java | 0 .../local/LocalIndicesCleanerTests.java | 4 + .../monitoring/collector/CollectorTests.java | 0 .../cluster/ClusterStatsCollectorTests.java | 33 +- .../ClusterStatsMonitoringDocTests.java | 6 +- .../indices/IndexRecoveryCollectorTests.java | 3 +- .../IndexRecoveryMonitoringDocTests.java | 0 .../indices/IndexStatsCollectorTests.java | 2 +- .../indices/IndexStatsMonitoringDocTests.java | 0 .../IndicesStatsMonitoringDocTests.java | 0 .../collector/ml/JobStatsCollectorTests.java | 2 +- .../ml/JobStatsMonitoringDocTests.java | 0 .../node/NodeStatsCollectorTests.java | 2 +- .../node/NodeStatsMonitoringDocTests.java | 0 .../shards/ShardsCollectorTests.java | 2 +- .../shards/ShardsMonitoringDocTests.java | 0 .../BaseFilteredMonitoringDocTestCase.java | 0 .../exporter/BaseMonitoringDocTestCase.java | 0 .../BytesReferenceMonitoringDocTests.java | 0 .../exporter/ClusterAlertsUtilTests.java | 0 .../monitoring/exporter/ExportersTests.java | 0 .../MonitoringTemplateUtilsTests.java | 0 ...stractPublishableHttpResourceTestCase.java | 0 .../http/ClusterAlertHttpResourceTests.java | 0 .../HttpExportBulkResponseListenerTests.java | 0 .../exporter/http/HttpExporterIT.java | 4 + .../http/HttpExporterResourceTests.java | 0 .../exporter/http/HttpExporterTests.java | 0 .../exporter/http/HttpHostBuilderTests.java | 0 .../exporter/http/HttpResourceTests.java | 0 .../exporter/http/MockHttpResource.java | 0 .../exporter/http/MultiHttpResourceTests.java | 0 .../http/NodeFailureListenerTests.java | 0 .../http/PipelineHttpResourceTests.java | 0 .../http/PublishableHttpResourceTests.java | 0 .../monitoring/exporter/http/SchemeTests.java | 0 ...SecurityHttpClientConfigCallbackTests.java | 0 .../http/TemplateHttpResourceTests.java | 0 .../TimeoutRequestConfigCallbackTests.java | 0 .../http/VersionHttpResourceTests.java | 0 .../http/WatcherExistsHttpResourceTests.java | 0 .../local/LocalExporterIntegTestCase.java | 6 +- .../local/LocalExporterIntegTests.java | 5 +- .../LocalExporterResourceIntegTests.java | 4 + .../monitoring/integration/MonitoringIT.java | 2 +- .../monitoring/test/MockIngestPlugin.java | 0 .../test/MonitoringIntegTestCase.java | 33 +- .../src/test/resources/monitoring-test.json | 10 + plugin/security/build.gradle | 89 ++- .../forbidden/ldap-signatures.txt | 0 .../x-pack => security/src/main/bin}/certgen | 0 .../src/main/bin}/certgen.bat | 0 .../x-pack => security/src/main/bin}/certutil | 0 .../src/main/bin}/certutil.bat | 0 .../x-pack => security/src/main/bin}/migrate | 0 .../src/main/bin}/migrate.bat | 0 .../src/main/bin}/setup-passwords | 0 .../src/main/bin}/setup-passwords.bat | 0 .../src/main/bin}/syskeygen | 0 .../src/main/bin}/syskeygen.bat | 0 .../x-pack => security/src/main/bin}/users | 0 .../src/main/bin}/users.bat | 0 .../src/main/config}/role_mapping.yml | 0 .../src/main/config}/roles.yml | 0 .../x-pack => security/src/main/config}/users | 0 .../src/main/config}/users_roles | 0 .../security/PkiRealmBootstrapCheck.java | 4 +- .../xpack/security/Security.java | 328 +++++----- .../xpack/security/SecurityFeatureSet.java | 88 +-- .../security/SecurityLifecycleService.java | 3 +- .../security/TokenSSLBootstrapCheck.java | 0 .../security/action/SecurityActionMapper.java | 0 .../action/filter/SecurityActionFilter.java | 6 +- .../BulkShardRequestInterceptor.java | 4 +- ...cumentLevelSecurityRequestInterceptor.java | 4 +- .../IndicesAliasesRequestInterceptor.java | 4 +- .../interceptor/RequestInterceptor.java | 0 .../interceptor/ResizeRequestInterceptor.java | 4 +- .../interceptor/SearchRequestInterceptor.java | 0 .../interceptor/UpdateRequestInterceptor.java | 0 .../realm/TransportClearRealmCacheAction.java | 8 +- .../role/TransportClearRolesCacheAction.java | 4 +- .../role/TransportDeleteRoleAction.java | 4 +- .../action/role/TransportGetRolesAction.java | 3 +- .../action/role/TransportPutRoleAction.java | 4 +- .../TransportDeleteRoleMappingAction.java | 0 .../TransportGetRoleMappingsAction.java | 0 .../TransportPutRoleMappingAction.java | 0 .../token/TransportCreateTokenAction.java | 0 .../token/TransportInvalidateTokenAction.java | 0 .../token/TransportRefreshTokenAction.java | 0 .../user/TransportAuthenticateAction.java | 0 .../user/TransportChangePasswordAction.java | 0 .../user/TransportDeleteUserAction.java | 0 .../action/user/TransportGetUsersAction.java | 0 .../user/TransportHasPrivilegesAction.java | 0 .../action/user/TransportPutUserAction.java | 0 .../user/TransportSetEnabledAction.java | 0 .../xpack/security/audit/AuditLevel.java | 0 .../xpack/security/audit/AuditTrail.java | 0 .../security/audit/AuditTrailService.java | 0 .../xpack/security/audit/AuditUtil.java | 0 .../security/audit/index/IndexAuditTrail.java | 10 +- .../audit/index/IndexNameResolver.java | 0 .../audit/logfile/LoggingAuditTrail.java | 0 .../security/authc/AuthenticationService.java | 0 .../security/authc/ExpiredTokenRemover.java | 0 .../xpack/security/authc/InternalRealms.java | 38 +- .../xpack/security/authc/Realms.java | 22 +- .../xpack/security/authc/TokenService.java | 83 +-- .../xpack/security/authc/UserToken.java | 0 .../esnative/ESNativeRealmMigrateTool.java | 0 .../security/authc/esnative/NativeRealm.java | 13 +- .../authc/esnative/NativeUsersStore.java | 0 .../authc/esnative/ReservedRealm.java | 0 .../authc/esnative/UserAndPassword.java | 0 .../esnative/tool/CommandLineHttpClient.java | 0 .../esnative/tool/SetupPasswordTool.java | 0 .../xpack/security/authc/file/FileRealm.java | 12 +- .../authc/file/FileUserPasswdStore.java | 0 .../authc/file/FileUserRolesStore.java | 0 .../security/authc/file/tool/UsersTool.java | 4 +- .../ldap/ActiveDirectoryGroupsResolver.java | 4 +- .../ldap/ActiveDirectorySessionFactory.java | 80 +-- .../xpack/security/authc/ldap/LdapRealm.java | 43 +- .../authc/ldap/LdapSessionFactory.java | 22 +- .../ldap/LdapUserSearchSessionFactory.java | 68 +-- .../authc/ldap/PoolingSessionFactory.java | 40 +- .../authc/ldap/SearchGroupsResolver.java | 41 +- .../ldap/UserAttributeGroupsResolver.java | 13 +- .../authc/ldap/support/LdapLoadBalancing.java | 22 +- .../ldap/support/LdapMetaDataResolver.java | 10 +- .../authc/ldap/support/LdapSession.java | 0 .../authc/ldap/support/LdapUtils.java | 0 .../authc/ldap/support/SessionFactory.java | 56 +- .../xpack/security/authc/pki/PkiRealm.java | 57 +- .../authc/pki/X509AuthenticationToken.java | 0 .../security/authc/support/CachingRealm.java | 0 .../support/CachingUsernamePasswordRealm.java | 26 +- .../security/authc/support/DnRoleMapper.java | 19 +- .../RoleMappingFileBootstrapCheck.java | 3 +- .../authc/support/UserRoleMapper.java | 0 .../authc/support/UsernamePasswordRealm.java | 0 .../support/mapper/CompositeRoleMapper.java | 3 - .../mapper/NativeRoleMappingStore.java | 0 .../security/authz/AuthorizationService.java | 18 +- .../security/authz/AuthorizationUtils.java | 0 .../security/authz/AuthorizedIndices.java | 0 .../authz/IndicesAndAliasesResolver.java | 9 +- .../SecuritySearchOperationListener.java | 0 .../SecurityIndexSearcherWrapper.java | 3 +- .../authz/store/CompositeRolesStore.java | 0 .../authz/store/NativeRolesStore.java | 0 .../security/crypto/tool/SystemKeyTool.java | 4 +- .../xpack/security/rest/RemoteHostHeader.java | 0 .../security/rest/SecurityRestFilter.java | 0 .../rest/action/RestAuthenticateAction.java | 0 .../rest/action/SecurityBaseRestHandler.java | 2 +- .../action/oauth2/RestGetTokenAction.java | 0 .../oauth2/RestInvalidateTokenAction.java | 0 .../realm/RestClearRealmCacheAction.java | 0 .../role/RestClearRolesCacheAction.java | 0 .../action/role/RestDeleteRoleAction.java | 0 .../rest/action/role/RestGetRolesAction.java | 0 .../rest/action/role/RestPutRoleAction.java | 0 .../RestDeleteRoleMappingAction.java | 0 .../RestGetRoleMappingsAction.java | 0 .../rolemapping/RestPutRoleMappingAction.java | 0 .../action/user/RestChangePasswordAction.java | 0 .../action/user/RestDeleteUserAction.java | 0 .../rest/action/user/RestGetUsersAction.java | 0 .../action/user/RestHasPrivilegesAction.java | 0 .../rest/action/user/RestPutUserAction.java | 0 .../action/user/RestSetEnabledAction.java | 0 .../support/AbstractSecurityModule.java | 0 .../support/FileAttributesChecker.java | 0 .../support/IndexLifecycleManager.java | 6 +- .../xpack/security/support/SecurityFiles.java | 0 .../SecurityServerTransportInterceptor.java | 0 .../transport/ServerTransportFilter.java | 0 .../security/transport/filter/IPFilter.java | 0 .../transport/filter/PatternRule.java | 0 .../filter/SecurityIpFilterRule.java | 0 .../netty4/IpFilterRemoteAddressFilter.java | 0 .../SecurityNetty4HttpServerTransport.java | 0 .../netty4/SecurityNetty4ServerTransport.java | 4 +- .../transport/nio/SSLChannelContext.java | 0 .../security/transport/nio/SSLDriver.java | 0 .../transport/nio/SecurityNioTransport.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../AbstractPrivilegeTestCase.java | 0 .../integration/BulkUpdateTests.java | 3 +- .../integration/ClearRealmsCacheTests.java | 3 +- .../integration/ClearRolesCacheTests.java | 0 .../integration/ClusterPrivilegeTests.java | 0 .../DateMathExpressionIntegTests.java | 0 .../DocumentAndFieldLevelSecurityTests.java | 0 .../DocumentLevelSecurityRandomTests.java | 0 .../DocumentLevelSecurityTests.java | 5 +- .../FieldLevelSecurityRandomTests.java | 0 .../integration/FieldLevelSecurityTests.java | 5 +- .../integration/IndexPrivilegeTests.java | 0 ...onsWithAliasesWildcardsAndRegexsTests.java | 0 .../integration/KibanaUserRoleIntegTests.java | 0 .../MultipleIndicesPermissionsTests.java | 0 .../PermissionPrecedenceTests.java | 0 .../SecurityCachePermissionTests.java | 3 +- .../integration/SecurityClearScrollTests.java | 5 +- .../ShrinkIndexWithSecurityTests.java | 0 .../ldap/AbstractAdLdapRealmTestCase.java | 16 +- .../ldap/ActiveDirectoryRunAsTests.java | 0 .../integration/ldap/GroupMappingTests.java | 0 .../ldap/MultiGroupMappingTests.java | 0 .../ldap/MultipleAdRealmTests.java | 0 ...LicenseServiceSingleNodeSecurityTests.java | 0 .../LicenseServiceWithSecurityTests.java | 5 +- .../elasticsearch/license/LicensingTests.java | 28 +- .../license/XPackLicenseStateTests.java | 19 +- .../test/NativeRealmIntegTestCase.java | 6 +- .../test/SecurityIntegTestCase.java | 46 +- .../test/SecuritySettingsSource.java | 44 +- .../test/SecurityTestsUtils.java | 0 .../SecurityServerTransportServiceTests.java | 0 .../xpack/security/LocalStateSecurity.java | 58 ++ .../security/PkiRealmBootstrapCheckTests.java | 6 +- .../security/ScrollHelperIntegTests.java | 0 .../xpack/security/SecurityContextTests.java | 0 .../security/SecurityFeatureSetTests.java | 6 +- .../SecurityLifecycleServiceTests.java | 6 +- .../xpack/security/SecurityPluginTests.java | 3 +- .../xpack/security/SecuritySettingsTests.java | 30 +- .../xpack/security/SecurityTests.java | 54 +- .../xpack/security/TemplateUpgraderTests.java | 0 .../security/TokenSSLBootsrapCheckTests.java | 0 .../action/SecurityActionMapperTests.java | 0 .../filter/DestructiveOperationsTests.java | 0 .../filter/SecurityActionFilterTests.java | 0 ...IndicesAliasesRequestInterceptorTests.java | 5 +- .../ResizeRequestInterceptorTests.java | 5 +- .../action/role/PutRoleBuilderTests.java | 0 .../role/TransportDeleteRoleActionTests.java | 0 .../role/TransportGetRolesActionTests.java | 0 .../role/TransportPutRoleActionTests.java | 0 .../PutRoleMappingRequestTests.java | 0 .../TransportGetRoleMappingsActionTests.java | 0 .../TransportPutRoleMappingActionTests.java | 0 .../action/token/CreateTokenRequestTests.java | 0 .../HasPrivilegesRequestBuilderTests.java | 0 .../user/PutUserRequestBuilderTests.java | 0 .../action/user/PutUserRequestTests.java | 0 .../TransportAuthenticateActionTests.java | 0 .../TransportChangePasswordActionTests.java | 10 +- .../user/TransportDeleteUserActionTests.java | 0 .../user/TransportGetUsersActionTests.java | 0 .../TransportHasPrivilegesActionTests.java | 0 .../user/TransportPutUserActionTests.java | 4 +- .../user/TransportSetEnabledActionTests.java | 0 .../xpack/security/audit/AuditLevelTests.java | 0 .../audit/AuditTrailServiceTests.java | 0 .../xpack/security/audit/AuditUtilTests.java | 0 .../security/audit/index/AuditTrailTests.java | 4 +- .../index/IndexAuditTrailMutedTests.java | 0 .../audit/index/IndexAuditTrailTests.java | 22 +- .../RemoteIndexAuditTrailStartingTests.java | 11 +- .../audit/logfile/CapturingLogger.java | 0 .../logfile/LoggingAuditTrailFilterTests.java | 0 .../audit/logfile/LoggingAuditTrailTests.java | 0 .../authc/AuthenticationServiceTests.java | 0 .../security/authc/InternalRealmsTests.java | 11 +- .../security/authc/RealmSettingsTests.java | 0 .../xpack/security/authc/RealmsTests.java | 65 +- .../xpack/security/authc/RunAsIntegTests.java | 26 +- .../security/authc/TokenAuthIntegTests.java | 33 +- .../security/authc/TokenServiceTests.java | 0 .../xpack/security/authc/UserTokenTests.java | 0 .../esnative/ESNativeMigrateToolTests.java | 0 .../ESNativeRealmMigrateToolTests.java | 5 +- .../authc/esnative/NativeRealmIntegTests.java | 13 +- .../authc/esnative/NativeRealmTests.java | 0 .../authc/esnative/NativeUsersStoreTests.java | 0 .../esnative/ReservedRealmIntegTests.java | 0 .../authc/esnative/ReservedRealmTests.java | 0 .../esnative/tool/SetupPasswordToolTests.java | 0 .../security/authc/file/FileRealmTests.java | 0 .../authc/file/FileUserPasswdStoreTests.java | 8 +- .../authc/file/FileUserRolesStoreTests.java | 4 +- .../AbstractActiveDirectoryIntegTests.java | 11 +- .../ActiveDirectoryGroupsResolverTests.java | 0 .../authc/ldap/ActiveDirectoryRealmTests.java | 60 +- .../ActiveDirectorySessionFactoryTests.java | 15 +- .../ldap/CancellableLdapRunnableTests.java | 0 .../authc/ldap/GroupsResolverTestCase.java | 0 .../security/authc/ldap/LdapRealmTests.java | 37 +- .../authc/ldap/LdapSessionFactoryTests.java | 5 +- .../security/authc/ldap/LdapTestUtils.java | 5 +- .../LdapUserSearchSessionFactoryTests.java | 23 +- .../SearchGroupsResolverInMemoryTests.java | 0 .../UserAttributeGroupsResolverTests.java | 0 .../authc/ldap/support/LDAPServersTests.java | 0 .../ldap/support/LdapLoadBalancingTests.java | 28 +- .../support/LdapMetaDataResolverTests.java | 0 .../authc/ldap/support/LdapTestCase.java | 28 +- .../SessionFactoryLoadBalancingTests.java | 0 .../ldap/support/SessionFactoryTests.java | 8 +- .../authc/pki/PkiAuthenticationTests.java | 11 +- .../authc/pki/PkiOptionalClientAuthTests.java | 4 +- .../security/authc/pki/PkiRealmTests.java | 6 +- .../security/authc/support/BCryptTests.java | 0 .../CachingUsernamePasswordRealmTests.java | 14 +- .../authc/support/DnRoleMapperTests.java | 8 +- .../security/authc/support/HasherTests.java | 0 .../RoleMappingFileBootstrapCheckTests.java | 2 +- .../support/UsernamePasswordTokenTests.java | 0 .../mapper/ExpressionRoleMappingTests.java | 0 .../mapper/NativeUserRoleMapperTests.java | 0 .../expressiondsl/ExpressionParserTests.java | 7 +- .../expressiondsl/FieldPredicateTests.java | 0 .../xpack/security/authz/AnalyzeTests.java | 0 .../authz/AuthorizationServiceTests.java | 86 +-- .../authz/AuthorizationUtilsTests.java | 0 .../authz/AuthorizedIndicesTests.java | 0 .../security/authz/IndexAliasesTests.java | 0 .../authz/IndicesAndAliasesResolverTests.java | 6 +- .../security/authz/ReadActionsTests.java | 0 .../security/authz/RoleDescriptorTests.java | 0 .../security/authz/SecurityScrollTests.java | 6 +- .../SecuritySearchOperationListenerTests.java | 0 .../security/authz/WriteActionsTests.java | 0 .../DocumentSubsetReaderTests.java | 0 ...ldDataCacheWithFieldSubsetReaderTests.java | 0 .../accesscontrol/FieldExtractorTests.java | 0 .../accesscontrol/FieldSubsetReaderTests.java | 0 .../IndicesAccessControlTests.java | 0 .../accesscontrol/IndicesPermissionTests.java | 0 .../accesscontrol/OptOutQueryCacheTests.java | 0 ...yIndexSearcherWrapperIntegrationTests.java | 0 ...SecurityIndexSearcherWrapperUnitTests.java | 0 .../SetSecurityUserProcessorFactoryTests.java | 0 .../SetSecurityUserProcessorTests.java | 0 .../FieldPermissionsCacheTests.java | 0 .../permission/FieldPermissionsTests.java | 0 .../authz/permission/PermissionTests.java | 0 .../authz/privilege/PrivilegeTests.java | 0 .../authz/store/CompositeRolesStoreTests.java | 4 +- .../authz/store/FileRolesStoreTests.java | 4 +- .../authz/store/NativeRolesStoreTests.java | 3 +- .../security/rest/RestRequestFilterTests.java | 0 .../rest/SecurityRestFilterTests.java | 6 +- .../action/RestAuthenticateActionTests.java | 3 +- .../action/SecurityBaseRestHandlerTests.java | 0 .../oauth2/RestGetTokenActionTests.java | 6 +- .../user/HasPrivilegesRestResponseTests.java | 0 .../security/support/AutomatonsTests.java | 0 .../IndexLifecycleManagerIntegTests.java | 0 .../support/IndexLifecycleManagerTests.java | 0 .../security/support/ValidationTests.java | 0 .../security/test/SecurityTestUtils.java | 0 ...curityServerTransportInterceptorTests.java | 0 ...ServerTransportFilterIntegrationTests.java | 29 +- .../transport/ServerTransportFilterTests.java | 0 .../transport/filter/IPFilterTests.java | 5 +- .../filter/IpFilteringIntegrationTests.java | 0 .../filter/IpFilteringUpdateTests.java | 0 .../transport/filter/PatternRuleTests.java | 0 .../filter/SecurityIpFilterRuleTests.java | 0 .../DNSOnlyHostnameVerificationTests.java | 15 +- .../netty4/IPHostnameVerificationTests.java | 0 .../IpFilterRemoteAddressFilterTests.java | 0 ...ecurityNetty4HttpServerTransportTests.java | 0 .../SecurityNetty4ServerTransportTests.java | 0 .../netty4/SslHostnameVerificationTests.java | 4 +- .../transport/ssl/EllipticCurveSSLTests.java | 0 .../transport/ssl/SslIntegrationTests.java | 6 +- .../transport/ssl/SslMultiPortTests.java | 64 +- .../transport/ssl/SslNullCipherTests.java | 0 .../user/AnonymousUserIntegTests.java | 0 .../security/user/AnonymousUserTests.java | 0 .../xpack/security/user/SystemUserTests.java | 0 .../xpack/security/user/UserTests.java | 0 .../xpack/security/user/XPackUserTests.java | 4 +- .../xpack/ssl/SSLClientAuthTests.java | 6 +- .../xpack/ssl/SSLReloadIntegTests.java | 7 +- .../xpack/ssl/SSLTrustRestrictionsTests.java | 0 .../IndexLifecycleManagerTests-template.json | 0 ...ssing-version-security-index-template.json | 0 .../security/action/role/roles2xformat.json | 0 .../xpack/security/authc/file/users | 0 .../xpack/security/authc/file/users_roles | 0 .../xpack/security/authc/ldap/ad-schema.ldif | 0 .../xpack/security/authc/ldap/ad.ldif | 0 .../security/authc/ldap/role_mapping.yml | 0 .../ldap/support/ldapWithGroupSearch.yml | 0 .../ldap/support/ldapWithRoleMapping.yml | 0 .../security/authc/ldap/support/ldaptrust.jks | Bin .../authc/ldap/support/seven-seas.ldif | 0 .../xpack/security/authc/pki/role_mapping.yml | 0 .../security/authc/support/role_mapping.yml | 0 .../security/authz/store/default_roles.yml | 0 .../security/authz/store/invalid_roles.yml | 0 .../security/authz/store/reserved_roles.yml | 0 .../xpack/security/authz/store/roles.yml | 0 .../security/authz/store/roles2xformat.json | 0 .../security/authz/store/roles2xformat.yml | 0 .../keystore/testnode-different-passwords.jks | Bin .../xpack/security/keystore/testnode.cert | 0 .../xpack/security/keystore/testnode.jks | Bin .../keystore/truststore-testnode-only.jks | Bin .../xpack/security/plugin/roles.yml | 0 .../elasticsearch/xpack/security/plugin/users | 0 .../xpack/security/plugin/users_roles | 0 .../ssl/certs/simple/README.asciidoc | 36 ++ .../ssl/certs/simple/active-directory-ca.crt | 23 + .../transport/ssl/certs/simple/openldap.crt | 24 + .../transport/ssl/certs/simple/openldap.der | Bin 0 -> 1035 bytes .../ssl/certs/simple/openssl_config.cnf | 35 ++ .../ssl/certs/simple/prime256v1-cert.pem | 15 + .../certs/simple/prime256v1-key-noparam.pem | 5 + .../ssl/certs/simple/prime256v1-key.pem | 8 + .../simple/testclient-client-profile.crt | 21 + .../simple/testclient-client-profile.jks | Bin 0 -> 3300 bytes .../simple/testclient-client-profile.p12 | Bin 0 -> 2648 bytes .../simple/testclient-client-profile.pem | 30 + .../transport/ssl/certs/simple/testclient.crt | 23 + .../transport/ssl/certs/simple/testclient.jks | Bin 0 -> 3358 bytes .../transport/ssl/certs/simple/testclient.p12 | Bin 0 -> 2666 bytes .../transport/ssl/certs/simple/testclient.pem | 30 + .../certs/simple/testnode-client-profile.crt | 21 + .../certs/simple/testnode-client-profile.jks | Bin 0 -> 3239 bytes .../certs/simple/testnode-client-profile.p12 | Bin 0 -> 2636 bytes .../certs/simple/testnode-client-profile.pem | 30 + .../simple/testnode-different-passwords.jks | Bin 0 -> 2339 bytes .../ssl/certs/simple/testnode-ip-only.crt | 21 + .../ssl/certs/simple/testnode-ip-only.jks | Bin 0 -> 2232 bytes .../certs/simple/testnode-no-subjaltname.cert | 20 + .../certs/simple/testnode-no-subjaltname.jks | Bin 0 -> 6284 bytes .../transport/ssl/certs/simple/testnode.crt | 23 + .../transport/ssl/certs/simple/testnode.jks | Bin 0 -> 6452 bytes .../transport/ssl/certs/simple/testnode.p12 | Bin 0 -> 2654 bytes .../transport/ssl/certs/simple/testnode.pem | 30 + .../certs/simple/truststore-testnode-only.jks | Bin 0 -> 1048 bytes plugin/sql/build.gradle | 8 +- .../org/elasticsearch/xpack/XPackPlugin.java | 517 ---------------- .../logstash/LogstashSecurityExtension.java | 34 -- .../xpack/ml/MachineLearningFeatureSet.java | 319 ---------- .../ml/MachineLearningSecurityExtension.java | 47 -- .../MonitoringSecurityExtension.java | 79 --- .../security/StackSecurityExtension.java | 68 --- .../authz/store/ReservedRolesStore.java | 37 -- .../watcher/WatcherSecurityExtension.java | 55 -- ...ticsearch.xpack.security.SecurityExtension | 5 - .../meta-plugin-descriptor.properties | 21 + .../xpack/CompositeTestingXPackPlugin.java | 72 +++ .../xpack/TimeWarpedXPackPlugin.java | 35 -- .../authz/store/ReservedRolesStoreTests.java | 50 +- .../xpack/test/rest/XPackRestIT.java | 15 +- .../xpack/watcher/test/TimeWarpedWatcher.java | 72 --- .../rest-api-spec/test/xpack/10_basic.yml | 10 +- plugin/upgrade/build.gradle | 35 ++ .../xpack/upgrade/IndexUpgradeCheck.java | 5 +- .../upgrade/IndexUpgradeCheckFactory.java | 0 .../xpack/upgrade/IndexUpgradeService.java | 0 .../xpack/upgrade/InternalIndexReindexer.java | 0 .../elasticsearch/xpack/upgrade/Upgrade.java | 21 +- .../actions/TransportIndexUpgradeAction.java | 0 .../TransportIndexUpgradeInfoAction.java | 4 +- .../upgrade/rest/RestIndexUpgradeAction.java | 0 .../rest/RestIndexUpgradeInfoAction.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../xpack/upgrade/IndexUpgradeIT.java | 0 .../upgrade/IndexUpgradeIntegTestCase.java | 6 +- .../upgrade/IndexUpgradeServiceTests.java | 0 .../xpack/upgrade/IndexUpgradeTasksIT.java | 2 +- .../upgrade/InternalIndexReindexerIT.java | 0 .../IndexUpgradeActionRequestTests.java | 0 .../IndexUpgradeInfoActionRequestTests.java | 0 .../IndexUpgradeInfoActionResponseTests.java | 0 plugin/watcher/build.gradle | 64 +- .../x-pack => watcher/src/main/bin}/croneval | 0 .../src/main/bin}/croneval.bat | 0 .../EncryptSensitiveDataBootstrapCheck.java | 4 +- .../elasticsearch/xpack/watcher/Watcher.java | 105 ++-- .../xpack/watcher/WatcherClientHelper.java | 0 .../xpack/watcher/WatcherFeatureSet.java | 45 +- .../watcher/WatcherIndexingListener.java | 0 .../watcher/WatcherLifeCycleService.java | 10 +- .../xpack/watcher/WatcherService.java | 0 .../xpack/watcher/actions/ActionBuilders.java | 0 .../watcher/actions/email/EmailAction.java | 0 .../actions/email/EmailActionFactory.java | 0 .../actions/email/ExecutableEmailAction.java | 0 .../hipchat/ExecutableHipChatAction.java | 0 .../actions/hipchat/HipChatAction.java | 0 .../actions/hipchat/HipChatActionFactory.java | 0 .../actions/index/ExecutableIndexAction.java | 0 .../watcher/actions/index/IndexAction.java | 0 .../actions/index/IndexActionFactory.java | 0 .../actions/jira/ExecutableJiraAction.java | 0 .../watcher/actions/jira/JiraAction.java | 0 .../actions/jira/JiraActionFactory.java | 0 .../logging/ExecutableLoggingAction.java | 0 .../actions/logging/LoggingAction.java | 0 .../actions/logging/LoggingActionFactory.java | 0 .../watcher/actions/logging/LoggingLevel.java | 0 .../pagerduty/ExecutablePagerDutyAction.java | 0 .../actions/pagerduty/PagerDutyAction.java | 0 .../pagerduty/PagerDutyActionFactory.java | 0 .../actions/slack/ExecutableSlackAction.java | 0 .../watcher/actions/slack/SlackAction.java | 0 .../actions/slack/SlackActionFactory.java | 0 .../webhook/ExecutableWebhookAction.java | 0 .../actions/webhook/WebhookAction.java | 0 .../actions/webhook/WebhookActionFactory.java | 0 .../watcher/client/WatchSourceBuilders.java | 0 .../xpack/watcher/common/http/HttpClient.java | 0 .../watcher/common/http/HttpContentType.java | 0 .../xpack/watcher/common/http/HttpMethod.java | 0 .../xpack/watcher/common/http/HttpProxy.java | 0 .../watcher/common/http/HttpRequest.java | 0 .../common/http/HttpRequestTemplate.java | 0 .../watcher/common/http/HttpResponse.java | 0 .../watcher/common/http/HttpSettings.java | 0 .../xpack/watcher/common/http/Scheme.java | 0 .../common/http/SizeLimitInputStream.java | 0 .../common/http/auth/ApplicableHttpAuth.java | 0 .../watcher/common/http/auth/HttpAuth.java | 0 .../common/http/auth/HttpAuthFactory.java | 0 .../common/http/auth/HttpAuthRegistry.java | 0 .../http/auth/basic/ApplicableBasicAuth.java | 0 .../common/http/auth/basic/BasicAuth.java | 0 .../http/auth/basic/BasicAuthFactory.java | 0 .../xpack/watcher/common/stats/Counters.java | 0 .../watcher/common/text/TextTemplate.java | 0 .../common/text/TextTemplateEngine.java | 0 .../condition/AbstractCompareCondition.java | 0 .../condition/ArrayCompareCondition.java | 0 .../watcher/condition/CompareCondition.java | 0 .../condition/InternalAlwaysCondition.java | 0 .../watcher/condition/LenientCompare.java | 0 .../watcher/condition/NeverCondition.java | 0 .../watcher/condition/ScriptCondition.java | 0 .../execution/AsyncTriggerEventConsumer.java | 0 .../watcher/execution/CurrentExecutions.java | 0 .../watcher/execution/ExecutionService.java | 0 .../execution/InternalWatchExecutor.java | 4 +- .../execution/ManualExecutionContext.java | 0 .../execution/SyncTriggerEventConsumer.java | 0 .../execution/TriggeredExecutionContext.java | 0 .../watcher/execution/TriggeredWatch.java | 0 .../execution/TriggeredWatchStore.java | 23 +- .../watcher/execution/WatchExecutor.java | 0 .../xpack/watcher/history/HistoryStore.java | 20 +- .../xpack/watcher/input/InputBuilders.java | 0 .../xpack/watcher/input/InputFactory.java | 0 .../xpack/watcher/input/InputRegistry.java | 0 .../xpack/watcher/input/chain/ChainInput.java | 0 .../input/chain/ChainInputFactory.java | 0 .../input/chain/ExecutableChainInput.java | 0 .../input/http/ExecutableHttpInput.java | 0 .../xpack/watcher/input/http/HttpInput.java | 0 .../watcher/input/http/HttpInputFactory.java | 0 .../input/none/ExecutableNoneInput.java | 0 .../watcher/input/none/NoneInputFactory.java | 0 .../input/search/ExecutableSearchInput.java | 0 .../watcher/input/search/SearchInput.java | 0 .../input/search/SearchInputFactory.java | 0 .../input/simple/ExecutableSimpleInput.java | 0 .../watcher/input/simple/SimpleInput.java | 0 .../input/simple/SimpleInputFactory.java | 0 .../transform/ExecutableTransformInput.java | 0 .../input/transform/TransformInput.java | 0 .../transform/TransformInputFactory.java | 0 .../notification/NotificationService.java | 0 .../watcher/notification/email/Account.java | 0 .../notification/email/Attachment.java | 0 .../notification/email/Authentication.java | 0 .../notification/email/DataAttachment.java | 0 .../watcher/notification/email/Email.java | 0 .../notification/email/EmailService.java | 0 .../notification/email/EmailTemplate.java | 0 .../notification/email/HtmlSanitizer.java | 0 .../watcher/notification/email/Profile.java | 0 .../email/attachment/DataAttachment.java | 0 .../attachment/DataAttachmentParser.java | 0 .../attachment/EmailAttachmentParser.java | 0 .../email/attachment/EmailAttachments.java | 0 .../attachment/EmailAttachmentsParser.java | 0 .../HttpEmailAttachementParser.java | 0 .../attachment/HttpRequestAttachment.java | 0 .../email/attachment/ReportingAttachment.java | 0 .../attachment/ReportingAttachmentParser.java | 0 .../email/support/BodyPartSource.java | 0 .../notification/hipchat/HipChatAccount.java | 0 .../notification/hipchat/HipChatMessage.java | 0 .../notification/hipchat/HipChatServer.java | 0 .../notification/hipchat/HipChatService.java | 0 .../hipchat/IntegrationAccount.java | 0 .../notification/hipchat/SentMessages.java | 0 .../notification/hipchat/UserAccount.java | 0 .../notification/hipchat/V1Account.java | 0 .../notification/jira/JiraAccount.java | 0 .../watcher/notification/jira/JiraIssue.java | 0 .../notification/jira/JiraService.java | 0 .../notification/pagerduty/IncidentEvent.java | 0 .../pagerduty/IncidentEventContext.java | 0 .../pagerduty/IncidentEventDefaults.java | 0 .../pagerduty/PagerDutyAccount.java | 0 .../pagerduty/PagerDutyService.java | 0 .../notification/pagerduty/SentEvent.java | 0 .../notification/slack/SentMessages.java | 0 .../notification/slack/SlackAccount.java | 0 .../notification/slack/SlackService.java | 0 .../notification/slack/message/Action.java | 0 .../slack/message/Attachment.java | 0 .../slack/message/DynamicAttachments.java | 0 .../notification/slack/message/Field.java | 0 .../slack/message/MessageElement.java | 0 .../slack/message/SlackMessage.java | 0 .../slack/message/SlackMessageDefaults.java | 0 .../watcher/rest/WatcherRestHandler.java | 0 .../rest/action/RestAckWatchAction.java | 0 .../rest/action/RestActivateWatchAction.java | 0 .../rest/action/RestDeleteWatchAction.java | 0 .../rest/action/RestExecuteWatchAction.java | 0 .../rest/action/RestGetWatchAction.java | 0 .../rest/action/RestPutWatchAction.java | 0 .../rest/action/RestWatchServiceAction.java | 0 .../rest/action/RestWatcherStatsAction.java | 0 .../watcher/support/ArrayObjectIterator.java | 0 .../xpack/watcher/support/Strings.java | 0 .../xpack/watcher/support/Variables.java | 0 .../support/WatcherIndexTemplateRegistry.java | 34 +- .../support/XContentFilterKeysUtils.java | 0 .../search/WatcherSearchTemplateRequest.java | 0 .../search/WatcherSearchTemplateService.java | 0 .../watcher/transform/TransformBuilders.java | 0 .../script/ExecutableScriptTransform.java | 0 .../transform/script/ScriptTransform.java | 0 .../script/ScriptTransformFactory.java | 0 .../search/ExecutableSearchTransform.java | 0 .../transform/search/SearchTransform.java | 0 .../search/SearchTransformFactory.java | 0 .../actions/WatcherTransportAction.java | 4 +- .../actions/ack/TransportAckWatchAction.java | 0 .../TransportActivateWatchAction.java | 0 .../delete/TransportDeleteWatchAction.java | 0 .../execute/TransportExecuteWatchAction.java | 4 +- .../actions/get/TransportGetWatchAction.java | 0 .../actions/put/TransportPutWatchAction.java | 0 .../TransportWatcherServiceAction.java | 0 .../stats/TransportWatcherStatsAction.java | 0 .../watcher/trigger/TriggerBuilders.java | 0 .../xpack/watcher/trigger/TriggerEngine.java | 0 .../xpack/watcher/trigger/TriggerService.java | 0 .../watcher/trigger/manual/ManualTrigger.java | 0 .../trigger/manual/ManualTriggerEngine.java | 0 .../trigger/manual/ManualTriggerEvent.java | 0 .../xpack/watcher/trigger/schedule/Cron.java | 0 .../trigger/schedule/CronSchedule.java | 0 .../trigger/schedule/CronnableSchedule.java | 0 .../trigger/schedule/DailySchedule.java | 0 .../trigger/schedule/HourlySchedule.java | 0 .../trigger/schedule/IntervalSchedule.java | 0 .../trigger/schedule/MonthlySchedule.java | 0 .../watcher/trigger/schedule/Schedule.java | 0 .../trigger/schedule/ScheduleRegistry.java | 0 .../trigger/schedule/ScheduleTrigger.java | 0 .../schedule/ScheduleTriggerEngine.java | 0 .../schedule/ScheduleTriggerEvent.java | 0 .../watcher/trigger/schedule/Schedules.java | 0 .../trigger/schedule/WeeklySchedule.java | 0 .../trigger/schedule/YearlySchedule.java | 0 .../engine/TickerScheduleTriggerEngine.java | 0 .../trigger/schedule/support/DayOfWeek.java | 0 .../trigger/schedule/support/DayTimes.java | 0 .../trigger/schedule/support/Month.java | 0 .../trigger/schedule/support/MonthTimes.java | 0 .../trigger/schedule/support/Times.java | 0 .../trigger/schedule/support/WeekTimes.java | 0 .../trigger/schedule/support/YearTimes.java | 0 .../trigger/schedule/tool/CronEvalTool.java | 0 .../xpack/watcher/watch/WatchParser.java | 0 .../xpack/watcher/watch/WatchStoreUtils.java | 0 .../watcher/watch/clock/HaltedClock.java | 0 .../plugin-metadata/plugin-security.policy | 50 ++ .../NotificationServiceTests.java | 0 ...cryptSensitiveDataBootstrapCheckTests.java | 0 .../watcher/WatcherClientHelperTests.java | 0 .../xpack/watcher/WatcherFeatureSetTests.java | 6 +- .../watcher/WatcherIndexingListenerTests.java | 0 .../watcher/WatcherLifeCycleServiceTests.java | 9 +- .../WatcherMetaDataSerializationTests.java | 6 +- .../xpack/watcher/WatcherPluginTests.java | 6 +- .../xpack/watcher/WatcherServiceTests.java | 0 .../actions/ActionErrorIntegrationTests.java | 0 .../watcher/actions/ActionWrapperTests.java | 0 .../actions/TimeThrottleIntegrationTests.java | 12 +- .../actions/email/EmailActionTests.java | 0 .../actions/email/EmailAttachmentTests.java | 4 +- .../hipchat/HipChatActionFactoryTests.java | 0 .../actions/hipchat/HipChatActionTests.java | 0 .../actions/index/IndexActionTests.java | 0 .../jira/ExecutableJiraActionTests.java | 0 .../actions/jira/JiraActionFactoryTests.java | 0 .../watcher/actions/jira/JiraActionTests.java | 0 .../actions/logging/LoggingActionTests.java | 0 .../PagerDutyActionFactoryTests.java | 0 .../pagerduty/PagerDutyActionTests.java | 0 .../slack/ExecutableSlackActionTests.java | 0 .../slack/SlackActionFactoryTests.java | 0 .../actions/slack/SlackActionTests.java | 0 .../actions/throttler/AckThrottlerTests.java | 0 .../throttler/ActionThrottleTests.java | 0 .../throttler/PeriodThrottlerTests.java | 0 .../throttler/WatchThrottlerTests.java | 0 .../actions/webhook/WebhookActionTests.java | 0 .../webhook/WebhookHttpsIntegrationTests.java | 0 .../webhook/WebhookIntegrationTests.java | 0 .../watcher/common/http/HttpClientTests.java | 0 .../http/HttpConnectionTimeoutTests.java | 0 .../common/http/HttpReadTimeoutTests.java | 0 .../common/http/HttpRequestTemplateTests.java | 0 .../watcher/common/http/HttpRequestTests.java | 0 .../common/http/HttpResponseTests.java | 0 .../http/SizeLimitInputStreamTests.java | 0 .../watcher/common/stats/CountersTests.java | 0 .../common/text/TextTemplateTests.java | 0 .../condition/AlwaysConditionTests.java | 0 .../ArrayCompareConditionSearchTests.java | 1 + .../condition/ArrayCompareConditionTests.java | 0 .../CompareConditionSearchTests.java | 0 .../condition/CompareConditionTests.java | 0 .../condition/NeverConditionTests.java | 0 .../condition/ScriptConditionTests.java | 0 .../watcher/crypto/CryptoServiceTests.java | 0 .../execution/ExecutionServiceTests.java | 0 .../execution/TriggeredWatchStoreTests.java | 24 +- .../history/HistoryActionConditionTests.java | 0 .../watcher/history/HistoryStoreTests.java | 4 +- .../HistoryTemplateEmailMappingsTests.java | 2 +- .../HistoryTemplateHttpMappingsTests.java | 10 +- ...storyTemplateIndexActionMappingsTests.java | 2 +- ...storyTemplateSearchInputMappingsTests.java | 4 +- .../HistoryTemplateTimeMappingsTests.java | 2 +- ...HistoryTemplateTransformMappingsTests.java | 0 .../watcher/input/InputRegistryTests.java | 0 .../watcher/input/chain/ChainInputTests.java | 4 +- .../input/chain/ChainIntegrationTests.java | 0 .../chain/ExecutableChainInputTests.java | 0 .../watcher/input/http/HttpInputTests.java | 0 .../input/simple/SimpleInputTests.java | 0 .../input/transform/TransformInputTests.java | 0 .../notification/email/AccountTests.java | 0 .../notification/email/AccountsTests.java | 0 .../email/DataAttachmentTests.java | 0 .../email/EmailSecretsIntegrationTests.java | 1 - .../notification/email/EmailServiceTests.java | 0 .../email/EmailTemplateTests.java | 0 .../notification/email/EmailTests.java | 0 .../email/HtmlSanitizerTests.java | 0 .../notification/email/ProfileTests.java | 0 .../attachment/DataAttachmentParserTests.java | 0 .../EmailAttachmentParsersTests.java | 0 .../HttpEmailAttachementParserTests.java | 0 .../ReportingAttachmentParserTests.java | 0 .../email/support/EmailServer.java | 0 .../hipchat/HipChatAccountsTests.java | 0 .../hipchat/HipChatMessageTests.java | 0 .../hipchat/HipChatServiceTests.java | 0 .../hipchat/IntegrationAccountTests.java | 0 .../hipchat/UserAccountTests.java | 0 .../notification/hipchat/V1AccountTests.java | 0 .../notification/jira/JiraAccountTests.java | 0 .../notification/jira/JiraIssueTests.java | 0 .../pagerduty/IncidentEventDefaultsTests.java | 0 .../pagerduty/PagerDutyAccountsTests.java | 0 .../message/SlackMessageDefaultsTests.java | 0 .../slack/message/SlackMessageTests.java | 0 .../action/RestExecuteWatchActionTests.java | 0 .../watcher/support/FilterXContentTests.java | 0 .../xpack/watcher/support/VariablesTests.java | 0 .../support/WatcherDateTimeUtilsTests.java | 0 .../WatcherIndexTemplateRegistryTests.java | 22 +- .../watcher/support/WatcherUtilsTests.java | 0 .../WatcherSearchTemplateRequestTests.java | 0 .../support/xcontent/MapPathTests.java | 0 .../support/xcontent/XContentSourceTests.java | 0 .../AbstractWatcherIntegrationTestCase.java | 68 +-- .../xpack/watcher/test/LocalStateWatcher.java | 34 ++ .../watcher/test/MockTextTemplateEngine.java | 0 .../xpack/watcher/test/TimeWarpedWatcher.java | 108 ++++ .../WatchExecutionContextMockBuilder.java | 0 .../xpack/watcher/test/WatcherTestUtils.java | 0 .../bench/ScheduleEngineTriggerBenchmark.java | 0 .../WatcherExecutorServiceBenchmark.java | 27 +- .../bench/WatcherScheduleEngineBenchmark.java | 11 +- .../test/integration/BasicWatcherTests.java | 0 .../test/integration/BootStrapTests.java | 21 +- .../ExecutionVarsIntegrationTests.java | 0 .../test/integration/HipChatServiceTests.java | 9 +- .../integration/HistoryIntegrationTests.java | 0 .../HttpSecretsIntegrationTests.java | 0 .../integration/PagerDutyServiceTests.java | 0 .../test/integration/SearchInputTests.java | 0 .../integration/SearchTransformTests.java | 0 .../test/integration/SlackServiceTests.java | 0 .../test/integration/WatchAckTests.java | 6 +- .../test/integration/WatchMetadataTests.java | 4 +- .../transform/TransformIntegrationTests.java | 0 .../transform/chain/ChainTransformTests.java | 0 .../script/ScriptTransformTests.java | 0 .../action/WatchRequestValidationTests.java | 0 .../action/activate/ActivateWatchTests.java | 0 .../action/delete/DeleteWatchTests.java | 5 +- .../execute/ExecuteWatchRequestTests.java | 0 .../action/execute/ExecuteWatchTests.java | 0 .../transport/action/get/GetWatchTests.java | 0 .../put/PutWatchSerializationTests.java | 0 .../put/TransportPutWatchActionTests.java | 0 .../trigger/ScheduleTriggerEngineMock.java | 0 .../trigger/schedule/CronScheduleTests.java | 0 .../trigger/schedule/DailyScheduleTests.java | 0 .../trigger/schedule/HourlyScheduleTests.java | 0 .../schedule/IntervalScheduleTests.java | 0 .../schedule/MonthlyScheduleTests.java | 0 .../schedule/ScheduleRegistryTests.java | 0 .../trigger/schedule/ScheduleTestCase.java | 0 .../schedule/ScheduleTriggerEventTests.java | 0 .../trigger/schedule/WeeklyScheduleTests.java | 0 .../trigger/schedule/YearlyScheduleTests.java | 0 .../engine/TickerScheduleEngineTests.java | 0 .../schedule/tool/CronEvalToolTests.java | 0 .../watch/WatchStatusIntegrationTests.java | 2 +- .../xpack/watcher/watch/WatchStatusTests.java | 0 .../xpack/watcher/watch/WatchTests.java | 0 .../xpack/watcher/watch/clock/ClockTests.java | 0 .../xpack/security/keystore/testnode.jks | Bin 0 -> 6766 bytes .../keystore/truststore-testnode-only.jks | Bin 0 -> 943 bytes .../certs/simple/testnode-no-subjaltname.jks | Bin 0 -> 6284 bytes qa/audit-tests/build.gradle | 12 +- .../xpack/security/audit/IndexAuditIT.java | 14 +- qa/core-rest-tests-with-security/build.gradle | 3 +- qa/full-cluster-restart/build.gradle | 22 +- qa/ml-basic-multi-node/build.gradle | 3 +- qa/ml-disabled/build.gradle | 3 +- qa/ml-no-bootstrap-tests/build.gradle | 3 +- qa/ml-single-node-tests/build.gradle | 3 +- qa/multi-cluster-search-security/build.gradle | 4 +- qa/multi-node/build.gradle | 2 +- qa/openldap-tests/build.gradle | 5 +- .../org/elasticsearch/test/OpenLdapTests.java | 3 +- .../authc/ldap/SearchGroupsResolverTests.java | 2 +- qa/reindex-tests-with-security/build.gradle | 5 +- .../xpack/security/ReindexWithSecurityIT.java | 26 +- qa/rolling-upgrade/build.gradle | 18 +- .../TokenBackwardsCompatibilityIT.java | 10 +- qa/security-client-tests/build.gradle | 6 +- .../qa/SecurityTransportClientIT.java | 13 +- qa/security-example-extension/build.gradle | 6 +- .../example/realm/CustomRealmIT.java | 3 +- .../example/role/CustomRolesProviderIT.java | 4 +- qa/security-migrate-tests/build.gradle | 3 +- .../xpack/security/MigrateToolTestCase.java | 2 +- qa/security-setup-password-tests/build.gradle | 5 +- qa/security-tools-tests/build.gradle | 14 + .../authc/file/tool/UsersToolTests.java | 42 +- .../crypto/tool/SystemKeyToolTests.java | 4 +- .../support/FileAttributesCheckerTests.java | 0 .../security/support/SecurityFilesTests.java | 0 .../ssl/CertificateGenerateToolTests.java | 74 +-- .../xpack/ssl/CertificateToolTests.java | 112 ++-- .../build.gradle | 2 +- qa/smoke-test-ml-with-security/build.gradle | 3 +- .../smoketest/MlWithSecurityIT.java | 8 +- .../build.gradle | 4 +- qa/smoke-test-plugins-ssl/build.gradle | 19 +- .../SmokeTestMonitoringWithSecurityIT.java | 6 +- qa/smoke-test-plugins/build.gradle | 10 +- ...SmokeTestPluginsClientYamlTestSuiteIT.java | 1 + .../build.gradle | 4 +- .../build.gradle | 3 +- .../smoketest/WatcherWithMustacheIT.java | 4 +- .../build.gradle | 2 +- .../smoketest/WatcherWithPainlessIT.java | 4 +- .../build.gradle | 2 +- ...cherWithSecurityClientYamlTestSuiteIT.java | 4 +- qa/smoke-test-watcher/build.gradle | 2 +- ...SmokeTestWatcherClientYamlTestSuiteIT.java | 4 +- qa/transport-client-tests/build.gradle | 2 +- qa/tribe-tests-with-license/build.gradle | 11 +- .../license/TribeTransportTestCase.java | 43 +- .../elasticsearch/test/LicensingTribeIT.java | 7 +- .../monitoring/MonitoringPluginTests.java | 17 +- .../monitoring/MonitoringTribeTests.java | 3 +- qa/tribe-tests-with-security/build.gradle | 7 +- .../test/TribeWithSecurityIT.java | 24 +- .../xpack/security/SecurityTribeTests.java | 5 +- qa/vagrant/build.gradle | 2 +- transport-client/build.gradle | 2 + .../client/PreBuiltXPackTransportClient.java | 6 +- .../PreBuiltXPackTransportClientTests.java | 5 +- 1826 files changed, 7722 insertions(+), 4185 deletions(-) delete mode 100644 plugin/bin/x-pack/x-pack-env delete mode 100644 plugin/bin/x-pack/x-pack-env.bat rename plugin/{security => core}/licenses/bcpkix-jdk15on-1.58.jar.sha1 (100%) rename plugin/{security => core}/licenses/bcprov-jdk15on-1.58.jar.sha1 (100%) rename plugin/{security => core}/licenses/bouncycastle-LICENSE.txt (100%) rename plugin/{security => core}/licenses/bouncycastle-NOTICE.txt (100%) create mode 100644 plugin/core/licenses/commons-LICENSE.txt create mode 100644 plugin/core/licenses/commons-NOTICE.txt create mode 100644 plugin/core/licenses/commons-codec-1.10.jar.sha1 create mode 100644 plugin/core/licenses/commons-logging-1.1.3.jar.sha1 create mode 100644 plugin/core/licenses/httpasyncclient-4.1.2.jar.sha1 create mode 100644 plugin/core/licenses/httpclient-4.5.2.jar.sha1 create mode 100644 plugin/core/licenses/httpclient-LICENSE.txt create mode 100644 plugin/core/licenses/httpclient-NOTICE.txt create mode 100644 plugin/core/licenses/httpcore-4.4.5.jar.sha1 rename plugin/{security => core}/licenses/unboundid-ldapsdk-3.2.0.jar.sha1 (100%) rename plugin/{security => core}/licenses/unboundid-ldapsdk-LICENSE.txt (100%) rename plugin/{security => core}/licenses/unboundid-ldapsdk-NOTICE.txt (100%) rename plugin/{bin/x-pack => core/src/main/bin}/extension (100%) rename plugin/{bin/x-pack => core/src/main/bin}/extension.bat (100%) create mode 100644 plugin/core/src/main/bin/x-pack-env create mode 100644 plugin/core/src/main/bin/x-pack-env.bat rename plugin/{config/x-pack => core/src/main/config}/log4j2.properties (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/common/network/InetAddressHelper.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/CryptUtils.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/ExpirationCallback.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/LicenseService.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/LicenseUtils.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/LicenseVerifier.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/LicensesMetaData.java (97%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/Licensing.java (88%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/LicensingClient.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/RestDeleteLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/RestGetTrialStatus.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/RestPostStartTrialLicense.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/RestPutLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/SelfGeneratedLicense.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/TransportGetLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/TransportGetTrialStatusAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/TransportPostStartTrialAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/license/package-info.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/EmptyXPackFeatureSet.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/XPackClient.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/XPackClientPlugin.java rename plugin/core/src/main/java/org/elasticsearch/xpack/{XpackField.java => XPackField.java} (92%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/XPackPlugin.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java (98%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/common/IteratingActionListener.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/common/socket/SocketAccess.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java (90%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtension.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionCli.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionPolicy.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurity.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionsService.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSetUsage.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetUsage.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningField.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ml/client/MachineLearningClient.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/ml/notifications/AuditorField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetUsage.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/monitoring/client/MonitoringClient.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackUsageAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/scheduler/SchedulerEngine.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/ScrollHelper.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java (94%) delete mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityExtension.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSetUsage.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/SecuritySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/UserSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailField.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/Authentication.java (98%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationFailureHandler.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationResult.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationToken.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/DefaultAuthenticationFailureHandler.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealmsSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/KeyAndTimestamp.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java (96%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/RealmConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java (98%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/TokenMetaData.java (86%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealmSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactorySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactorySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactorySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactorySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverSettings.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSearchScope.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactorySettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperSettings.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordToken.java (98%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapperSettings.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverField.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReader.java (98%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractor.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReader.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControl.java (97%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCache.java (98%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessor.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/ClusterPermission.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissions.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCache.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsDefinition.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/IndicesPermission.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/Role.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/permission/RunAsPermission.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/privilege/ClusterPrivilege.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/privilege/HealthAndStatsPrivilege.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/privilege/IndexPrivilege.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/privilege/Privilege.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/privilege/SystemPrivilege.java (100%) delete mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ClientReservedRoles.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java (98%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/client/SecurityClient.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/rest/RestRequestFilter.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/support/NoOpLogger.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/transport/SSLExceptionHelper.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4Transport.java (93%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/BuiltinUserInfo.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/ElasticUser.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/InternalUserSerializationHelper.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/KibanaUser.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/LogstashSystemUser.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/SystemUser.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/XPackSecurityUser.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/security/user/XPackUser.java (93%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/CertUtils.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/CertificateGenerateTool.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/CertificateTool.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/CertificateTrustRestrictions.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/DefaultJDKTrustConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/KeyConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/PEMKeyConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/PEMTrustConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/RestrictedTrustManager.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/SSLConfiguration.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloader.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/SSLService.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/StoreKeyConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/StoreTrustConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheck.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/TrustAllConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/TrustConfig.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/action/TransportGetCertificateInfoAction.java (100%) rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/ssl/rest/RestGetCertificateInfoAction.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckVersion.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/UpgradeField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetUsage.java rename plugin/{ => core}/src/main/java/org/elasticsearch/xpack/watcher/client/WatcherClient.java (100%) create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStoreField.java create mode 100644 plugin/core/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryField.java rename plugin/{ => core}/src/main/plugin-metadata/plugin-security.policy (100%) rename plugin/{ => core}/src/main/resources/logstash-index-template.json (100%) rename plugin/{ => core}/src/main/resources/monitoring-alerts.json (100%) rename plugin/{ => core}/src/main/resources/monitoring-beats.json (100%) rename plugin/{ => core}/src/main/resources/monitoring-es.json (100%) rename plugin/{ => core}/src/main/resources/monitoring-kibana.json (100%) rename plugin/{ => core}/src/main/resources/monitoring-logstash.json (100%) rename plugin/{ => core}/src/main/resources/security-index-template.json (100%) rename plugin/{ => core}/src/main/resources/security_audit_log.json (100%) rename plugin/{ => core}/src/main/resources/triggered-watches.json (100%) rename plugin/{ => core}/src/main/resources/watch-history.json (100%) rename plugin/{ => core}/src/main/resources/watches.json (100%) rename plugin/{src/main/resources/org/elasticsearch => core/src/main/resources}/xpack/security/crypto/migrate.help (100%) rename plugin/{src/main/resources/org/elasticsearch => core/src/main/resources}/xpack/security/crypto/tool/syskey-generate.help (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/action/MockIndicesRequest.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/http/netty4/Netty4HttpMockUtil.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/AbstractLicenseServiceTestCase.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/AbstractLicensesIntegrationTestCase.java (85%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/ExpirationCallbackTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseClusterChangeTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseOperationModeTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseOperationModeUpdateTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseRegistrationTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseSerializationTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseServiceClusterNotRecoveredTests.java (92%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java (97%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicenseUtilsTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicensesAcknowledgementTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicensesManagerServiceTests.java (96%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicensesMetaDataSerializationTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/LicensesTransportTests.java (96%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/OperationModeFileWatcherTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/PutLicenseResponseTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/SelfGeneratedLicenseTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/TestUtils.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/license/UpgradeToTrialTests.java (92%) rename plugin/{ => core}/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java (95%) create mode 100644 plugin/core/src/test/java/org/elasticsearch/test/SecuritySettingsSourceField.java rename plugin/{ => core}/src/test/java/org/elasticsearch/test/TestMatchers.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/test/http/Headers.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/test/http/MockRequest.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/test/http/MockResponse.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/test/http/MockWebServer.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ClientHelperTests.java (100%) create mode 100644 plugin/core/src/test/java/org/elasticsearch/xpack/LocalStateCompositeXPackPlugin.java rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java (89%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/XPackSettingsTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java (70%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/common/IteratingActionListenerTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationChecksTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionRequestTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionResponseTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationIssueTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java (97%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java (98%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java (98%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionInfoTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurityTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionTestUtil.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionsServiceTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/CancelPersistentTaskRequestTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorFullRestartIT.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorIT.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorResponseTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceStatusTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/RestartPersistentTaskRequestTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java (90%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/CertUtilsTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfigTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustManagerTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloaderTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/SSLServiceTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/StoreKeyConfigTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheckTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/TestsSSLService.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/ssl/cert/CertificateInfoTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/template/TemplateUtilsTests.java (100%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java (97%) rename plugin/{ => core}/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockMock.java (100%) rename plugin/{ => core}/src/test/resources/monitoring-test.json (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/extensions/security/complex-x-pack-extension-security.policy (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/extensions/security/simple-x-pack-extension-security.policy (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/extensions/security/unresolved-x-pack-extension-security.policy (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem (100%) rename plugin/{ => core}/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks (100%) rename plugin/{ => core}/src/test/resources/private.key (100%) rename plugin/{ => core}/src/test/resources/public.key (100%) create mode 100644 plugin/deprecation/build.gradle rename plugin/{ => deprecation}/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java (92%) rename plugin/{ => deprecation}/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java (100%) rename plugin/{ => deprecation}/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java (100%) rename plugin/{ => deprecation}/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java (100%) rename plugin/{ => deprecation}/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java (98%) create mode 100644 plugin/deprecation/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => deprecation}/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java (100%) rename plugin/{ => graph}/src/main/java/org/elasticsearch/xpack/graph/Graph.java (78%) rename plugin/{ => graph}/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java (75%) rename plugin/{ => graph}/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java (99%) rename plugin/{ => graph}/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java (100%) create mode 100644 plugin/graph/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => graph}/src/test/java/org/elasticsearch/xpack/graph/GraphFeatureSetTests.java (97%) rename plugin/{ => graph}/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java (97%) create mode 100644 plugin/logstash/build.gradle rename plugin/{ => logstash}/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java (89%) rename plugin/{ => logstash}/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java (100%) create mode 100644 plugin/logstash/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => logstash}/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/InvalidLicenseEnforcer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java (88%) create mode 100644 plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceService.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/MlLifeCycleService.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteExpiredDataAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteFilterAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java (98%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportFlushJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportForecastJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetBucketsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarEventsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCategoriesAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsStatsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetInfluencersAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetModelSnapshotsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetOverallBucketsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetRecordsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportIsolateDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportKillProcessAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java (99%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostCalendarEventsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostDataAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPreviewDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutCalendarAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutDatafeedAction.java (99%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutFilterAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutJobAction.java (96%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportRevertModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java (99%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateCalendarJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateProcessAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportValidateDetectorAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/action/TransportValidateJobConfigAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJob.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilder.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManager.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelector.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/ProblemTracker.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorContext.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorContext.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedField.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFields.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorContext.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java (98%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/UpdateJobProcessNotifier.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataCountsPersister.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersister.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregator.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollector.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProcessor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProvider.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/CountingInputStream.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnostics.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/NativeController.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/NativeControllerHolder.java (93%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrl.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessPipes.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicator.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcess.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcess.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcess.java (98%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/ProcessContext.java (96%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/UpdateParams.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessor.java (99%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParser.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListener.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessor.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParams.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParams.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParams.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRange.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CannotParseTimestampException.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateTransformer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriter.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/WriterConstants.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReader.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessage.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandler.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/AbstractLeafNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/Level.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/MultiplyingNormalizerProcess.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NativeNormalizerProcess.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NativeNormalizerProcessFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/Normalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/Normalizer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerProcess.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerProcessFactory.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResult.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/PartitionScoreNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/RecordNormalizable.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/Renormalizer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdater.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizer.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandler.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/results/AutodetectResult.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/retention/AbstractExpiredJobDataRemover.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredForecastsRemover.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemover.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemover.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/job/retention/MlDataRemover.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/notifications/Auditor.java (95%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/RestDeleteExpiredDataAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarEventAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarEventsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPostCalendarEventAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestDeleteDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPreviewDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPutDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStopDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestUpdateDatafeedAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestDeleteFilterAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestPutFilterAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestCloseJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestFlushJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestForecastJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostJobUpdateAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPutJobAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestDeleteModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestRevertModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestUpdateModelSnapshotAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateDetectorAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateJobConfigAction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelper.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/utils/StatsAccumulator.java (100%) rename plugin/{ => ml}/src/main/java/org/elasticsearch/xpack/ml/utils/VolatileCursorIterator.java (100%) create mode 100644 plugin/ml/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => ml}/src/main/resources/org/elasticsearch/xpack/ml/transforms/exact.properties (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java (92%) create mode 100644 plugin/ml/src/test/java/org/elasticsearch/xpack/ml/LocalStateMachineLearning.java rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java (97%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java (92%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MlAssignmentNotifierTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MlClientHelperTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MlDailyManagementServiceTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MlInitializationServiceTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/DeleteCalendarEventActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/DeleteExpiredDataActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsStatsActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PostCalendarEventActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutFilterActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/StopDatafeedActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateCalendarJobActionResquestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateJobActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionResponseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/ValidateJobConfigActionRequestTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/util/PageParamsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/calendars/CalendarTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/calendars/ScheduledEventTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/ChunkingConfigTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobValidatorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelectorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedStateTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/ProblemTrackerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/ExtractorUtilsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactoryTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationTestUtils.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactoryTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectMemoryLimitIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/BasicRenormalizationIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteJobIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/DetectionRulesIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/InterimResultsDeletedAfterReopeningJobIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java (98%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/OverallBucketsIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/RestoreModelSnapshotIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/integration/UpdateInterimResultsIT.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java (98%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisConfigTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisLimitsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/CategorizationAnalyzerConfigTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/ConditionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/ConnectiveTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/DataFormatTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/DefaultDetectorDescriptionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectionRuleTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/JobStateTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTaskStatusTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java (99%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/OperatorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTypeTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobLookupTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/messages/MessagesTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/BatchedDocumentsIteratorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappingsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/InfluencersQueryBuilderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobProviderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersisterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockBatchedDocumentsIterator.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ResultsFilterBuilderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregatorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollectorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProviderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/CountingInputStreamTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnosticsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/DummyDataCountsReporter.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/NativeControllerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessPipesTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcessTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushAcknowledgementTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListenerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParamsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParamsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRangeTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/DataCountsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/MemoryStatusTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSnapshotTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/QuantilesTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvParserTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactoryTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandlerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizableTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizableTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizableTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResultTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdaterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandlerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketInfluencerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastRequestStatsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluenceTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/OverallBucketTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemoverTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemoverTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/GetModelSnapshotsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/UpdateModelSnapshotActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditMessageTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/notifications/LevelTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedActionTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java (95%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/test/SearchHitBuilder.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/IntervalsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/MlStringsTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/NameResolverTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/StatsAccumulatorTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/time/DateTimeFormatterTimestampConverterTests.java (100%) rename plugin/{ => ml}/src/test/java/org/elasticsearch/xpack/ml/utils/time/TimeUtilsTests.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java (81%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java (63%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkAction.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java (97%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollector.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportException.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListener.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilder.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListener.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/Scheme.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallback.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallback.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResource.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java (100%) rename plugin/{ => monitoring}/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java (100%) create mode 100644 plugin/monitoring/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json (100%) rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/elasticsearch_nodes.json (100%) rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json (100%) rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/kibana_version_mismatch.json (100%) rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/logstash_version_mismatch.json (100%) rename plugin/{ => monitoring}/src/main/resources/monitoring/watches/xpack_license_expiration.json (100%) rename plugin/{src/test/java/org/elasticsearch/xpack/monitoring/collector => monitoring/src/test/java/org/elasticsearch/xpack/monitoring}/BaseCollectorTestCase.java (85%) create mode 100644 plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/LocalStateMonitoring.java rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java (84%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java (95%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTestUtils.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java (96%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringIndexTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java (97%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/CollectorTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java (91%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java (98%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java (98%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java (98%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseFilteredMonitoringDocTestCase.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BaseMonitoringDocTestCase.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDocTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/AbstractPublishableHttpResourceTestCase.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListenerTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MockHttpResource.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListenerTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SchemeTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallbackTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallbackTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResourceTests.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java (95%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java (98%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java (99%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/test/MockIngestPlugin.java (100%) rename plugin/{ => monitoring}/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java (86%) create mode 100644 plugin/monitoring/src/test/resources/monitoring-test.json rename plugin/{ => security}/forbidden/ldap-signatures.txt (100%) rename plugin/{bin/x-pack => security/src/main/bin}/certgen (100%) rename plugin/{bin/x-pack => security/src/main/bin}/certgen.bat (100%) rename plugin/{bin/x-pack => security/src/main/bin}/certutil (100%) rename plugin/{bin/x-pack => security/src/main/bin}/certutil.bat (100%) rename plugin/{bin/x-pack => security/src/main/bin}/migrate (100%) rename plugin/{bin/x-pack => security/src/main/bin}/migrate.bat (100%) rename plugin/{bin/x-pack => security/src/main/bin}/setup-passwords (100%) rename plugin/{bin/x-pack => security/src/main/bin}/setup-passwords.bat (100%) rename plugin/{bin/x-pack => security/src/main/bin}/syskeygen (100%) rename plugin/{bin/x-pack => security/src/main/bin}/syskeygen.bat (100%) rename plugin/{bin/x-pack => security/src/main/bin}/users (100%) rename plugin/{bin/x-pack => security/src/main/bin}/users.bat (100%) rename plugin/{config/x-pack => security/src/main/config}/role_mapping.yml (100%) rename plugin/{config/x-pack => security/src/main/config}/roles.yml (100%) rename plugin/{config/x-pack => security/src/main/config}/users (100%) rename plugin/{config/x-pack => security/src/main/config}/users_roles (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java (95%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/Security.java (84%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java (60%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java (99%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/TokenSSLBootstrapCheck.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/SecurityActionMapper.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java (98%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptor.java (98%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/RequestInterceptor.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptor.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/SearchRequestInterceptor.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/interceptor/UpdateRequestInterceptor.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/realm/TransportClearRealmCacheAction.java (93%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/role/TransportClearRolesCacheAction.java (95%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleAction.java (94%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java (96%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleAction.java (95%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportDeleteRoleMappingAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/token/TransportRefreshTokenAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportPutUserAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/AuditLevel.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrail.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrailService.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java (99%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexNameResolver.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java (74%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java (93%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java (96%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/UserToken.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateTool.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java (85%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/UserAndPassword.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java (87%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java (99%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java (98%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java (87%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java (88%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java (86%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java (79%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java (77%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java (76%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java (85%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java (79%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java (88%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSession.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapUtils.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java (76%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java (79%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/pki/X509AuthenticationToken.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingRealm.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java (88%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java (91%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java (91%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/UserRoleMapper.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordRealm.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java (95%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizedIndices.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java (98%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListener.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java (99%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/RemoteHostHeader.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/SecurityRestFilter.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java (97%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestInvalidateTokenAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/realm/RestClearRealmCacheAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestClearRolesCacheAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestDeleteRoleAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestDeleteRoleMappingAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestDeleteUserAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/support/AbstractSecurityModule.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/support/FileAttributesChecker.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java (99%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/support/SecurityFiles.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/filter/PatternRule.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRule.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilter.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java (94%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLChannelContext.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLDriver.java (100%) rename plugin/{ => security}/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java (100%) create mode 100644 plugin/security/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityRandomTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/PermissionPrecedenceTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ldap/ActiveDirectoryRunAsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ldap/GroupMappingTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ldap/MultiGroupMappingTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/integration/ldap/MultipleAdRealmTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/license/LicenseServiceSingleNodeSecurityTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java (91%) rename plugin/{ => security}/src/test/java/org/elasticsearch/license/LicensingTests.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java (96%) rename plugin/{ => security}/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java (93%) rename plugin/{ => security}/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/test/SecurityTestsUtils.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/transport/SecurityServerTransportServiceTests.java (100%) create mode 100644 plugin/security/src/test/java/org/elasticsearch/xpack/security/LocalStateSecurity.java rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/ScrollHelperIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecurityContextTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/TemplateUpgraderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/TokenSSLBootsrapCheckTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/filter/DestructiveOperationsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java (96%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/role/PutRoleBuilderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/PutRoleMappingRequestTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/token/CreateTokenRequestTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestBuilderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/AuditLevelTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/AuditTrailServiceTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/logfile/CapturingLogger.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailFilterTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java (79%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java (91%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java (90%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/UserTokenTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/file/FileRealmTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java (89%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java (89%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/CancellableLdapRunnableTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/GroupsResolverTestCase.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java (94%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverInMemoryTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LDAPServersTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java (83%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java (90%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryLoadBalancingTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordTokenTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeUserRoleMapperTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java (96%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldPredicateTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/AnalyzeTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListenerTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReaderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractorTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReaderTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCacheTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorFactoryTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/privilege/PrivilegeTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java (99%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandlerTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java (95%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/rest/action/user/HasPrivilegesRestResponseTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/support/AutomatonsTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java (92%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java (98%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/filter/PatternRuleTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRuleTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java (93%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilterTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransportTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java (87%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslNullCipherTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/user/SystemUserTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java (100%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java (96%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java (96%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java (97%) rename plugin/{ => security}/src/test/java/org/elasticsearch/xpack/ssl/SSLTrustRestrictionsTests.java (100%) rename plugin/{ => security}/src/test/resources/IndexLifecycleManagerTests-template.json (100%) rename plugin/{ => security}/src/test/resources/missing-version-security-index-template.json (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/action/role/roles2xformat.json (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/file/users (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/file/users_roles (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad-schema.ldif (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad.ldif (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/role_mapping.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithGroupSearch.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithRoleMapping.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldaptrust.jks (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/seven-seas.ldif (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/pki/role_mapping.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authc/support/role_mapping.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/default_roles.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/invalid_roles.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/reserved_roles.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.json (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode-different-passwords.jks (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.cert (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/plugin/roles.yml (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/plugin/users (100%) rename plugin/{ => security}/src/test/resources/org/elasticsearch/xpack/security/plugin/users_roles (100%) create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem create mode 100644 plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/XPackPlugin.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashSecurityExtension.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningSecurityExtension.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringSecurityExtension.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/security/StackSecurityExtension.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherSecurityExtension.java delete mode 100644 plugin/src/main/resources/META-INF/services/org.elasticsearch.xpack.security.SecurityExtension create mode 100644 plugin/src/main/resources/meta-plugin-descriptor.properties create mode 100644 plugin/src/test/java/org/elasticsearch/xpack/CompositeTestingXPackPlugin.java delete mode 100644 plugin/src/test/java/org/elasticsearch/xpack/TimeWarpedXPackPlugin.java delete mode 100644 plugin/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java create mode 100644 plugin/upgrade/build.gradle rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java (97%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckFactory.java (100%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeService.java (100%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexer.java (100%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java (85%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeAction.java (100%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java (98%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeAction.java (100%) rename plugin/{ => upgrade}/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeInfoAction.java (100%) create mode 100644 plugin/upgrade/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIT.java (100%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java (94%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeServiceTests.java (100%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java (98%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexerIT.java (100%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeActionRequestTests.java (100%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionRequestTests.java (100%) rename plugin/{ => upgrade}/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionResponseTests.java (100%) rename plugin/{bin/x-pack => watcher/src/main/bin}/croneval (100%) rename plugin/{bin/x-pack => watcher/src/main/bin}/croneval.bat (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java (95%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java (91%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/WatcherClientHelper.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java (54%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java (96%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/ActionBuilders.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/ExecutableHipChatAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/ExecutableLoggingAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingLevel.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/ExecutablePagerDutyAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/ExecutableWebhookAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/client/WatchSourceBuilders.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpClient.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpContentType.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpMethod.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpProxy.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplate.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpResponse.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpSettings.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/Scheme.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStream.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/ApplicableHttpAuth.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuth.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthRegistry.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/ApplicableBasicAuth.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuth.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuthFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/stats/Counters.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplate.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateEngine.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/AbstractCompareCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/CompareCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/InternalAlwaysCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/NeverCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/condition/ScriptCondition.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/CurrentExecutions.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java (92%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/ManualExecutionContext.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredExecutionContext.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatch.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java (92%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutor.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java (87%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/InputBuilders.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/none/ExecutableNoneInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/search/ExecutableSearchInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/simple/ExecutableSimpleInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInput.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/NotificationService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Account.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Attachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Authentication.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplate.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizer.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Profile.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpRequestAttachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/email/support/BodyPartSource.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServer.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/SentMessages.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1Account.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssue.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEvent.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventContext.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaults.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SentMessages.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackAccount.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Action.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Attachment.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Field.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/MessageElement.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessage.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaults.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/ArrayObjectIterator.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/Strings.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/Variables.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java (84%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/XContentFilterKeysUtils.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransform.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/search/ExecutableSearchTransform.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransform.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransformFactory.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java (96%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/ack/TransportAckWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/activate/TransportActivateWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/delete/TransportDeleteWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/execute/TransportExecuteWatchAction.java (98%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/TransportGetWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/stats/TransportWatcherStatsAction.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerBuilders.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerEngine.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTrigger.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEngine.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEvent.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Cron.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronSchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronnableSchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailySchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlySchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalSchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlySchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTrigger.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEngine.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEvent.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedules.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklySchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlySchedule.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayOfWeek.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Month.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/MonthTimes.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Times.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/WeekTimes.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/YearTimes.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchStoreUtils.java (100%) rename plugin/{ => watcher}/src/main/java/org/elasticsearch/xpack/watcher/watch/clock/HaltedClock.java (100%) create mode 100644 plugin/watcher/src/main/plugin-metadata/plugin-security.policy rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/notification/NotificationServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheckTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherClientHelperTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java (94%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherIndexingListenerTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java (92%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java (96%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionErrorIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java (94%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java (98%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactoryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactoryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/AckThrottlerTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/ActionThrottleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/PeriodThrottlerTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/WatchThrottlerTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookHttpsIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpClientTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpConnectionTimeoutTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpReadTimeoutTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplateTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStreamTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/stats/CountersTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/AlwaysConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/NeverConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/crypto/CryptoServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java (97%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java (96%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java (97%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java (98%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java (97%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTransformMappingsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachmentTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java (99%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizerTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/ProfileTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/email/support/EmailServer.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessageTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccountTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccountTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1AccountTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssueTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaultsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccountsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaultsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/VariablesTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherDateTimeUtilsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java (91%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/MapPathTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/XContentSourceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java (94%) create mode 100644 plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/LocalStateWatcher.java rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/MockTextTemplateEngine.java (100%) create mode 100644 plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/WatchExecutionContextMockBuilder.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java (90%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java (98%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java (95%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/ExecutionVarsIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java (96%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HttpSecretsIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/PagerDutyServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SlackServiceTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java (98%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java (97%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/WatchRequestValidationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java (95%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchRequestTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailyScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlyScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlyScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEventTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklyScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlyScheduleTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalToolTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java (97%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java (100%) rename plugin/{ => watcher}/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockTests.java (100%) create mode 100644 plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks create mode 100644 plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks create mode 100644 plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks create mode 100644 qa/security-tools-tests/build.gradle rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java (94%) rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java (97%) rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/security/support/FileAttributesCheckerTests.java (100%) rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java (100%) rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java (98%) rename {plugin => qa/security-tools-tests}/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java (97%) 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 createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, + ResourceWatcherService resourceWatcherService, ScriptService scriptService, + NamedXContentRegistry xContentRegistry, Environment environment, + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + List components = new ArrayList<>(); + + // just create the reloader as it will pull all of the loaded ssl configurations and start watching them + new SSLConfigurationReloader(settings, environment, getSslService(), resourceWatcherService); + + setLicenseService(new LicenseService(settings, clusterService, getClock(), + environment, resourceWatcherService, getLicenseState())); + + // It is useful to override these as they are what guice is injecting into actions + components.add(getSslService()); + components.add(getLicenseService()); + components.add(getLicenseState()); + + return components; + } + + @Override + public List> getActions() { + List> actions = new ArrayList<>(); + actions.add(new ActionHandler<>(XPackInfoAction.INSTANCE, TransportXPackInfoAction.class)); + actions.add(new ActionHandler<>(XPackUsageAction.INSTANCE, TransportXPackUsageAction.class)); + actions.addAll(licensing.getActions()); + return actions; + } + + @Override + public List getClientActions() { + List actions = new ArrayList<>(); + actions.addAll(licensing.getClientActions()); + actions.addAll(super.getClientActions()); + return actions; + } + + @Override + public List getActionFilters() { + List filters = new ArrayList<>(); + filters.addAll(licensing.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.add(new RestXPackInfoAction(settings, restController)); + handlers.add(new RestXPackUsageAction(settings, restController)); + handlers.addAll(licensing.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, + indexNameExpressionResolver, nodesInCluster)); + return handlers; + } + + public static void bindFeatureSet(Binder binder, Class featureSet) { + Multibinder featureSetBinder = createFeatureSetMultiBinder(binder, featureSet); + featureSetBinder.addBinding().to(featureSet); + } + + public static Multibinder createFeatureSetMultiBinder(Binder binder, Class featureSet) { + binder.bind(featureSet).asEagerSingleton(); + return Multibinder.newSetBinder(binder, XPackFeatureSet.class); + } + + public static boolean transportClientMode(Settings settings) { + return TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())); + } + + public static Path resolveConfigFile(Environment env, String name) { + return env.configFile().resolve(XPackField.NAME).resolve(name); + } + + public static Path resolveXPackExtensionsFile(Environment env) { + return env.pluginsFile().resolve(XPackField.NAME).resolve("x-pack-security").resolve("extensions"); + } + +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/XPackSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackSettings.java index 95d8dfd4772..643580c2d7a 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/XPackSettings.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/XPackSettings.java @@ -6,9 +6,13 @@ package org.elasticsearch.xpack; import org.elasticsearch.common.network.NetworkModule; +import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.xpack.security.SecurityField; +import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.ssl.SSLClientAuth; import org.elasticsearch.xpack.ssl.SSLConfigurationSettings; import org.elasticsearch.xpack.ssl.VerificationMode; @@ -19,6 +23,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Optional; + +import static org.elasticsearch.xpack.security.SecurityField.USER_SETTING; /** * A container for xpack setting constants. @@ -121,7 +128,7 @@ public class XPackSettings { private static final SSLConfigurationSettings TRANSPORT_SSL = SSLConfigurationSettings.withPrefix(TRANSPORT_SSL_PREFIX); /** Returns all settings created in {@link XPackSettings}. */ - static List> getAllSettings() { + public static List> getAllSettings() { ArrayList> settings = new ArrayList<>(); settings.addAll(GLOBAL_SSL.getAllSettings()); settings.addAll(HTTP_SSL.getAllSettings()); @@ -138,6 +145,8 @@ public class XPackSettings { settings.add(HTTP_SSL_ENABLED); settings.add(RESERVED_REALM_ENABLED_SETTING); settings.add(TOKEN_SERVICE_ENABLED_SETTING); + settings.add(USER_SETTING); return Collections.unmodifiableList(settings); } + } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java index 0cbb050b646..d4084c195c1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackInfoResponse; import org.elasticsearch.license.License; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/action/TransportXPackUsageAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/common/IteratingActionListener.java b/plugin/core/src/main/java/org/elasticsearch/xpack/common/IteratingActionListener.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/common/IteratingActionListener.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/common/IteratingActionListener.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/common/socket/SocketAccess.java b/plugin/core/src/main/java/org/elasticsearch/xpack/common/socket/SocketAccess.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/common/socket/SocketAccess.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/common/socket/SocketAccess.java diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java index 1976e57d1e7..b1ab2bc2a00 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationInfoAction.java @@ -74,7 +74,7 @@ public class DeprecationInfoAction extends Action nodeSettingsIssues; private Map> indexSettingsIssues; - Response() { + public Response() { } public Response(List clusterSettingsIssues, @@ -157,7 +157,7 @@ public class DeprecationInfoAction extends Action nodesInfo, List nodesStats, ClusterState state, + public static DeprecationInfoAction.Response from(List nodesInfo, List nodesStats, ClusterState state, IndexNameExpressionResolver indexNameExpressionResolver, String[] indices, IndicesOptions indicesOptions, List>clusterSettingsChecks, diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java similarity index 90% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java index 9c34bd44163..7442d294338 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java @@ -14,6 +14,7 @@ import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.env.Environment; +import org.elasticsearch.xpack.XPackPlugin; import java.nio.file.Files; import java.nio.file.Path; @@ -50,7 +51,7 @@ class RemoveXPackExtensionCommand extends EnvironmentAwareCommand { void execute(Terminal terminal, String extensionName, Environment env) throws Exception { terminal.println("-> Removing " + Strings.coalesceToEmpty(extensionName) + "..."); - Path extensionDir = resolveXPackExtensionsFile(env).resolve(extensionName); + Path extensionDir = XPackPlugin.resolveXPackExtensionsFile(env).resolve(extensionName); if (Files.exists(extensionDir) == false) { throw new UserException(ExitCodes.USAGE, "Extension " + extensionName + " not found. Run 'bin/x-pack/extension list' to get list of installed extensions."); @@ -59,7 +60,7 @@ class RemoveXPackExtensionCommand extends EnvironmentAwareCommand { List extensionPaths = new ArrayList<>(); terminal.println(VERBOSE, "Removing: " + extensionDir); - Path tmpExtensionDir = resolveXPackExtensionsFile(env).resolve(".removing-" + extensionName); + Path tmpExtensionDir = XPackPlugin.resolveXPackExtensionsFile(env).resolve(".removing-" + extensionName); Files.move(extensionDir, tmpExtensionDir, StandardCopyOption.ATOMIC_MOVE); extensionPaths.add(tmpExtensionDir); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtension.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtension.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtension.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtension.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionCli.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionCli.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionCli.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionCli.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionPolicy.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionPolicy.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionPolicy.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionPolicy.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurity.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurity.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurity.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurity.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionsService.java b/plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionsService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionsService.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionsService.java diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSetUsage.java b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSetUsage.java new file mode 100644 index 00000000000..af2fdebe23c --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSetUsage.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.graph; + +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.xpack.XPackField; + +import java.io.IOException; + +public class GraphFeatureSetUsage extends XPackFeatureSet.Usage { + + public GraphFeatureSetUsage(StreamInput input) throws IOException { + super(input); + } + + public GraphFeatureSetUsage(boolean available, boolean enabled) { + super(XPackField.GRAPH, available, enabled); + } +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java index 7dc630da404..83a370aaf06 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/GraphExploreResponse.java @@ -40,11 +40,11 @@ public class GraphExploreResponse extends ActionResponse implements ToXContentOb private boolean returnDetailedInfo; static final String RETURN_DETAILED_INFO_PARAM = "returnDetailedInfo"; - GraphExploreResponse() { + public GraphExploreResponse() { } - GraphExploreResponse(long tookInMillis, boolean timedOut, ShardOperationFailedException[] shardFailures, Map vertices, - Map connections, boolean returnDetailedInfo) { + public GraphExploreResponse(long tookInMillis, boolean timedOut, ShardOperationFailedException[] shardFailures, + Map vertices, Map connections, boolean returnDetailedInfo) { this.tookInMillis = tookInMillis; this.timedOut = timedOut; this.shardFailures = shardFailures; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java index 83bd6f09f1d..5e1169bf18e 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Hop.java @@ -46,7 +46,7 @@ public class Hop { List vertices = null; QueryBuilder guidingQuery = null; - Hop(Hop parent) { + public Hop(Hop parent) { this.parentHop = parent; } @@ -132,11 +132,11 @@ public class Hop { return parentHop.getEffectiveVertexRequests(); } - int getNumberVertexRequests() { + public int getNumberVertexRequests() { return getEffectiveVertexRequests().size(); } - VertexRequest getVertexRequest(int requestNumber) { + public VertexRequest getVertexRequest(int requestNumber) { return getEffectiveVertexRequests().get(requestNumber); } } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java index ad5e6cd703a..44126ca49d4 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/Vertex.java @@ -28,7 +28,7 @@ public class Vertex implements ToXContentFragment { final long bg; long fg; - Vertex(String field, String term, double weight, int depth, long bg, long fg) { + public Vertex(String field, String term, double weight, int depth, long bg, long fg) { super(); this.field = field; this.term = term; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java index 140c4071b2a..fa816a13b2f 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/graph/action/VertexRequest.java @@ -32,7 +32,7 @@ public class VertexRequest { private int shardMinDocCount = DEFAULT_SHARD_MIN_DOC_COUNT; - VertexRequest() { + public VertexRequest() { } @@ -151,7 +151,7 @@ public class VertexRequest { return includes.values().toArray(new TermBoost[includes.size()]); } - String[] includeValuesAsStringArray() { + public String[] includeValuesAsStringArray() { String[] result = new String[includes.size()]; int i = 0; for (TermBoost tb : includes.values()) { @@ -160,7 +160,7 @@ public class VertexRequest { return result; } - String[] excludesAsArray() { + public String[] excludesAsArray() { return excludes.toArray(new String[excludes.size()]); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningClientActionPlugin.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningClientActionPlugin.java index 972b4661b08..c1bf5b2f079 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningClientActionPlugin.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningClientActionPlugin.java @@ -11,9 +11,4 @@ import org.elasticsearch.common.unit.TimeValue; public interface MachineLearningClientActionPlugin { - Setting MAX_MODEL_MEMORY_LIMIT = - Setting.memorySizeSetting("xpack.ml.max_model_memory_limit", new ByteSizeValue(0), - Setting.Property.Dynamic, Setting.Property.NodeScope); - - TimeValue STATE_PERSIST_RESTORE_TIMEOUT = TimeValue.timeValueMinutes(30); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetUsage.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetUsage.java new file mode 100644 index 00000000000..d57ed5a49f3 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetUsage.java @@ -0,0 +1,61 @@ +/* + * 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.ml; + +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; +import java.util.Objects; + +public class MachineLearningFeatureSetUsage extends XPackFeatureSet.Usage { + + protected static final String ALL = "_all"; + protected static final String JOBS_FIELD = "jobs"; + protected static final String DATAFEEDS_FIELD = "datafeeds"; + protected static final String COUNT = "count"; + protected static final String DETECTORS = "detectors"; + protected static final String MODEL_SIZE = "model_size"; + + private final Map jobsUsage; + private final Map datafeedsUsage; + + public MachineLearningFeatureSetUsage(boolean available, boolean enabled, Map jobsUsage, + Map datafeedsUsage) { + super(XPackField.MACHINE_LEARNING, available, enabled); + this.jobsUsage = Objects.requireNonNull(jobsUsage); + this.datafeedsUsage = Objects.requireNonNull(datafeedsUsage); + } + + public MachineLearningFeatureSetUsage(StreamInput in) throws IOException { + super(in); + this.jobsUsage = in.readMap(); + this.datafeedsUsage = in.readMap(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeMap(jobsUsage); + out.writeMap(datafeedsUsage); + } + + @Override + protected void innerXContent(XContentBuilder builder, Params params) throws IOException { + super.innerXContent(builder, params); + if (jobsUsage != null) { + builder.field(JOBS_FIELD, jobsUsage); + } + if (datafeedsUsage != null) { + builder.field(DATAFEEDS_FIELD, datafeedsUsage); + } + } + +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningField.java new file mode 100644 index 00000000000..18613854f98 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/MachineLearningField.java @@ -0,0 +1,22 @@ +/* + * 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.ml; + +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.unit.TimeValue; + +public final class MachineLearningField { + public static final Setting AUTODETECT_PROCESS = + Setting.boolSetting("xpack.ml.autodetect_process", true, Setting.Property.NodeScope); + public static final Setting MAX_MODEL_MEMORY_LIMIT = + Setting.memorySizeSetting("xpack.ml.max_model_memory_limit", new ByteSizeValue(0), + Setting.Property.Dynamic, Setting.Property.NodeScope); + public static final TimeValue STATE_PERSIST_RESTORE_TIMEOUT = TimeValue.timeValueMinutes(30); + + private MachineLearningField() {} + +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/CloseJobAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/CloseJobAction.java index 95571204997..910290b168d 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/CloseJobAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/CloseJobAction.java @@ -21,7 +21,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.tasks.Task; -import org.elasticsearch.xpack.ml.MachineLearningClientActionPlugin; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.ml.job.config.Job; import java.io.IOException; @@ -74,13 +74,13 @@ public class CloseJobAction extends Action buckets; - Response() { + public Response() { } - Response(QueryPage buckets) { + public Response(QueryPage buckets) { this.buckets = buckets; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsAction.java index efd7428e9b9..11ea9669e5c 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsAction.java @@ -77,7 +77,7 @@ public class GetCalendarEventsAction extends Action scheduledEvents; - Response() { + public Response() { } public Response(QueryPage scheduledEvents) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarsAction.java index 261ec0d2070..82f00f86ed6 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCalendarsAction.java @@ -162,7 +162,7 @@ public class GetCalendarsAction extends Action getCalendars() { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCategoriesAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCategoriesAction.java index a76106abf25..26622abccfb 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCategoriesAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetCategoriesAction.java @@ -79,7 +79,7 @@ Action getResult() { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetDatafeedsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetDatafeedsAction.java index 8f0d33df3ad..d42c1b67ce0 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetDatafeedsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetDatafeedsAction.java @@ -59,11 +59,11 @@ public class GetDatafeedsAction extends Action getFilters() { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetInfluencersAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetInfluencersAction.java index e6543186910..e009b4ba847 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetInfluencersAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetInfluencersAction.java @@ -87,7 +87,7 @@ extends Action influencers; - Response() { + public Response() { } - Response(QueryPage influencers) { + public Response(QueryPage influencers) { this.influencers = influencers; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetJobsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetJobsAction.java index 6d9df4770ae..2c61e92e094 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetJobsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetJobsAction.java @@ -56,11 +56,11 @@ public class GetJobsAction extends Action getExpandedJobsIds() { return expandedJobsIds; } @@ -177,7 +177,7 @@ public class GetJobsStatsAction extends Action taskFailures, List nodeFailures, + public Response(List taskFailures, List nodeFailures, QueryPage jobsStats) { super(taskFailures, nodeFailures); this.jobsStats = jobsStats; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsAction.java index f1540469ca3..5cc7695d466 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsAction.java @@ -88,7 +88,7 @@ extends Action getPage() { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsAction.java index bce6e5a124b..f980c40a386 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsAction.java @@ -121,7 +121,7 @@ public class GetOverallBucketsAction private Long end; private boolean allowNoJobs = true; - Request() { + public Request() { } public Request(String jobId) { @@ -291,11 +291,11 @@ public class GetOverallBucketsAction private QueryPage overallBuckets; - Response() { + public Response() { overallBuckets = new QueryPage<>(Collections.emptyList(), 0, OverallBucket.RESULTS_FIELD); } - Response(QueryPage overallBuckets) { + public Response(QueryPage overallBuckets) { this.overallBuckets = overallBuckets; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetRecordsAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetRecordsAction.java index b421917970d..4b919b74a3c 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetRecordsAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/GetRecordsAction.java @@ -87,7 +87,7 @@ public class GetRecordsAction extends Action records; - Response() { + public Response() { } - Response(QueryPage records) { + public Response(QueryPage records) { this.records = records; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/IsolateDatafeedAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/IsolateDatafeedAction.java index e7b88bec670..d1d5f99d32e 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/IsolateDatafeedAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/IsolateDatafeedAction.java @@ -81,10 +81,10 @@ public class IsolateDatafeedAction this.datafeedId = ExceptionsHelper.requireNonNull(datafeedId, DatafeedConfig.ID.getPreferredName()); } - Request() { + public Request() { } - String getDatafeedId() { + public String getDatafeedId() { return datafeedId; } @@ -154,7 +154,7 @@ public class IsolateDatafeedAction readFrom(in); } - Response() { + public Response() { super(null, null); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/KillProcessAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/KillProcessAction.java index 515399e031b..2ca6546eca2 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/KillProcessAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/KillProcessAction.java @@ -49,7 +49,7 @@ public class KillProcessAction extends Action scheduledEvents; - Request() { + public Request() { } public Request(String calendarId, List scheduledEvents) { @@ -144,7 +144,7 @@ public class PostCalendarEventsAction extends Action scheduledEvents; - Response() { + public Response() { } public Response(List scheduledEvents) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/PostDataAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/PostDataAction.java index 9880bf595bf..60c34b55f4c 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/PostDataAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/PostDataAction.java @@ -54,12 +54,12 @@ public class PostDataAction extends Action jobIdsToAdd; private Set jobIdsToRemove; - Request() { + public Request() { } public Request(String calendarId, Set jobIdsToAdd, Set jobIdsToRemove) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedAction.java index 3b293b6ff97..4144b39984a 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedAction.java @@ -54,7 +54,7 @@ public class UpdateDatafeedAction extends Action detectorUpdates, MlFilter filter, diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/ValidateDetectorAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/ValidateDetectorAction.java index 96a0728fabe..cfa6ef163fe 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/ValidateDetectorAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/ValidateDetectorAction.java @@ -58,7 +58,7 @@ extends Action exporters; + + public MonitoringFeatureSetUsage(StreamInput in) throws IOException { + super(in); + exporters = in.readMap(); + } + + public MonitoringFeatureSetUsage(boolean available, boolean enabled, Map exporters) { + super(XPackField.MONITORING, available, enabled); + this.exporters = exporters; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeMap(exporters); + } + + @Override + protected void innerXContent(XContentBuilder builder, Params params) throws IOException { + super.innerXContent(builder, params); + if (exporters != null) { + builder.field(ENABLED_EXPORTERS_XFIELD, exporters); + } + } +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponse.java b/plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponse.java index 80285f95580..10c68dcda50 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponse.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponse.java @@ -24,7 +24,7 @@ public class MonitoringBulkResponse extends ActionResponse { private long tookInMillis; private Error error; - MonitoringBulkResponse() { + public MonitoringBulkResponse() { } public MonitoringBulkResponse(long tookInMillis) { @@ -83,7 +83,7 @@ public class MonitoringBulkResponse extends ActionResponse { status = ExceptionsHelper.status(t); } - Error(StreamInput in) throws IOException { + public Error(StreamInput in) throws IOException { this(in.readException()); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/client/MonitoringClient.java b/plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/client/MonitoringClient.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/client/MonitoringClient.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/monitoring/client/MonitoringClient.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java b/plugin/core/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/rest/XPackRestHandler.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackUsageAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackUsageAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackUsageAction.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackUsageAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/scheduler/SchedulerEngine.java b/plugin/core/src/main/java/org/elasticsearch/xpack/scheduler/SchedulerEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/scheduler/SchedulerEngine.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/scheduler/SchedulerEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/ScrollHelper.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/ScrollHelper.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/ScrollHelper.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/ScrollHelper.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java similarity index 94% rename from plugin/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java index 0452d916661..b62bc136f81 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityContext.java @@ -26,16 +26,18 @@ public class SecurityContext { private final Logger logger; private final ThreadContext threadContext; + private final UserSettings userSettings; private final String nodeName; /** * Creates a new security context. - * If cryptoService is null, security is disabled and {@link #getUser()} - * and {@link #getAuthentication()} will always return null. + * If cryptoService is null, security is disabled and {@link UserSettings#getUser()} + * and {@link UserSettings#getAuthentication()} will always return null. */ public SecurityContext(Settings settings, ThreadContext threadContext) { this.logger = ServerLoggers.getLogger(getClass(), settings); this.threadContext = threadContext; + this.userSettings = new UserSettings(settings, threadContext); this.nodeName = Node.NODE_NAME_SETTING.get(settings); } @@ -100,7 +102,7 @@ public class SecurityContext { */ public void executeAfterRewritingAuthentication(Consumer consumer, Version version) { final StoredContext original = threadContext.newStoredContext(true); - final Authentication authentication = Objects.requireNonNull(getAuthentication()); + final Authentication authentication = Objects.requireNonNull(userSettings.getAuthentication()); try (ThreadContext.StoredContext ctx = threadContext.stashContext()) { setAuthentication(new Authentication(authentication.getUser(), authentication.getAuthenticatedBy(), authentication.getLookedUpBy(), version)); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityExtension.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityExtension.java deleted file mode 100644 index b26a0c24a03..00000000000 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityExtension.java +++ /dev/null @@ -1,26 +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; - -import org.elasticsearch.xpack.security.authz.RoleDescriptor; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * SPI interface to any plugins that want to provide custom extensions to aid the security module in functioning without - * needing to explicitly know about the behavior of the implementing plugin. - */ -public interface SecurityExtension { - - /** - * Gets a set of reserved roles, consisting of the role name and the descriptor. - */ - default Map getReservedRoles() { - return Collections.emptyMap(); - } -} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSetUsage.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSetUsage.java new file mode 100644 index 00000000000..92615b2e8c8 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSetUsage.java @@ -0,0 +1,95 @@ +/* + * 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; + +import org.elasticsearch.Version; +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.Collections; +import java.util.Map; + +public class SecurityFeatureSetUsage extends XPackFeatureSet.Usage { + + private static final String REALMS_XFIELD = "realms"; + private static final String ROLES_XFIELD = "roles"; + private static final String ROLE_MAPPING_XFIELD = "role_mapping"; + private static final String SSL_XFIELD = "ssl"; + private static final String AUDIT_XFIELD = "audit"; + private static final String IP_FILTER_XFIELD = "ipfilter"; + private static final String ANONYMOUS_XFIELD = "anonymous"; + + private Map realmsUsage; + private Map rolesStoreUsage; + private Map sslUsage; + private Map auditUsage; + private Map ipFilterUsage; + private Map anonymousUsage; + private Map roleMappingStoreUsage; + + public SecurityFeatureSetUsage(StreamInput in) throws IOException { + super(in); + realmsUsage = in.readMap(); + rolesStoreUsage = in.readMap(); + sslUsage = in.readMap(); + auditUsage = in.readMap(); + ipFilterUsage = in.readMap(); + if (in.getVersion().before(Version.V_6_0_0_beta1)) { + // system key has been removed but older send its usage, so read the map and ignore + in.readMap(); + } + anonymousUsage = in.readMap(); + roleMappingStoreUsage = in.readMap(); + } + + public SecurityFeatureSetUsage(boolean available, boolean enabled, Map realmsUsage, + Map rolesStoreUsage, Map roleMappingStoreUsage, + Map sslUsage, Map auditUsage, + Map ipFilterUsage, Map anonymousUsage) { + super(XPackField.SECURITY, available, enabled); + this.realmsUsage = realmsUsage; + this.rolesStoreUsage = rolesStoreUsage; + this.roleMappingStoreUsage = roleMappingStoreUsage; + this.sslUsage = sslUsage; + this.auditUsage = auditUsage; + this.ipFilterUsage = ipFilterUsage; + this.anonymousUsage = anonymousUsage; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeMap(realmsUsage); + out.writeMap(rolesStoreUsage); + out.writeMap(sslUsage); + out.writeMap(auditUsage); + out.writeMap(ipFilterUsage); + if (out.getVersion().before(Version.V_6_0_0_beta1)) { + // system key has been removed but older versions still expected it so send a empty map + out.writeMap(Collections.emptyMap()); + } + out.writeMap(anonymousUsage); + out.writeMap(roleMappingStoreUsage); + } + + @Override + protected void innerXContent(XContentBuilder builder, Params params) throws IOException { + super.innerXContent(builder, params); + if (enabled) { + builder.field(REALMS_XFIELD, realmsUsage); + builder.field(ROLES_XFIELD, rolesStoreUsage); + builder.field(ROLE_MAPPING_XFIELD, roleMappingStoreUsage); + builder.field(SSL_XFIELD, sslUsage); + builder.field(AUDIT_XFIELD, auditUsage); + builder.field(IP_FILTER_XFIELD, ipFilterUsage); + builder.field(ANONYMOUS_XFIELD, anonymousUsage); + } + } +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityField.java index 5ae55fd8c73..8e2a3050571 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityField.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityField.java @@ -5,10 +5,17 @@ */ package org.elasticsearch.xpack.security; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.xpack.XPackField; + +import java.util.Optional; public final class SecurityField { + public static final String NAME4 = XPackField.SECURITY + "4"; + public static final Setting> USER_SETTING = + new Setting<>(setting("user"), (String) null, Optional::ofNullable, Setting.Property.NodeScope); + private SecurityField() {} public static String setting(String setting) { @@ -17,6 +24,6 @@ public final class SecurityField { } public static String settingPrefix() { - return XpackField.featureSettingPrefix(XpackField.SECURITY) + "."; + return XPackField.featureSettingPrefix(XPackField.SECURITY) + "."; } } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceField.java new file mode 100644 index 00000000000..88a981e7454 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceField.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; + +public final class SecurityLifecycleServiceField { + public static final String SECURITY_TEMPLATE_NAME = "security-index-template"; + + private SecurityLifecycleServiceField() {} +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecuritySettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecuritySettings.java new file mode 100644 index 00000000000..5a4334bed65 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/SecuritySettings.java @@ -0,0 +1,52 @@ +/* + * 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; + +import org.elasticsearch.common.network.NetworkModule; +import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; + +import java.util.Optional; + +public final class SecuritySettings { + + public static Settings addTransportSettings(final Settings settings) { + final Settings.Builder builder = Settings.builder(); + if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings)) { + final String transportType = NetworkModule.TRANSPORT_TYPE_SETTING.get(settings); + if (SecurityField.NAME4.equals(transportType) == false) { + throw new IllegalArgumentException("transport type setting [" + NetworkModule.TRANSPORT_TYPE_KEY + + "] must be [" + SecurityField.NAME4 + "] but is [" + transportType + "]"); + } + } else { + // default to security4 + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4); + } + return builder.build(); + } + + public static Settings addUserSettings(final Settings settings) { + final Settings.Builder builder = Settings.builder(); + String authHeaderSettingName = ThreadContext.PREFIX + "." + UsernamePasswordToken.BASIC_AUTH_HEADER; + if (settings.get(authHeaderSettingName) == null) { + Optional userOptional = SecurityField.USER_SETTING.get(settings); // TODO migrate to securesetting! + userOptional.ifPresent(userSetting -> { + final int i = userSetting.indexOf(":"); + if (i < 0 || i == userSetting.length() - 1) { + throw new IllegalArgumentException("invalid [" + SecurityField.USER_SETTING.getKey() + + "] setting. must be in the form of \":\""); + } + String username = userSetting.substring(0, i); + String password = userSetting.substring(i + 1); + builder.put(authHeaderSettingName, UsernamePasswordToken.basicAuthHeaderValue(username, new SecureString(password))); + }); + } + return builder.build(); + } + +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/UserSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/UserSettings.java new file mode 100644 index 00000000000..b582f22fe0d --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/UserSettings.java @@ -0,0 +1,48 @@ +/* + * 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; + +import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.logging.ServerLoggers; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.xpack.security.authc.Authentication; +import org.elasticsearch.xpack.security.user.User; + +import java.io.IOException; + +public final class UserSettings { + private final Logger logger; + private final ThreadContext threadContext; + + UserSettings(Settings settings, ThreadContext threadContext) { + this.logger = ServerLoggers.getLogger(getClass(), settings); + this.threadContext = threadContext; + } + + + /** + * Returns the current user information, or null if the current request has no authentication info. + */ + public User getUser() { + Authentication authentication = getAuthentication(); + return authentication == null ? null : authentication.getUser(); + } + + /** + * Returns the authentication information, or null if the current request has no authentication info. + */ + public Authentication getAuthentication() { + try { + return Authentication.readFromContext(threadContext); + } catch (IOException e) { + // TODO: this seems bogus, the only way to get an ioexception here is from a corrupt or tampered + // auth header, which should be be audited? + logger.error("failed to read authentication", e); + return null; + } + } +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/action/realm/ClearRealmCacheRequest.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/action/realm/ClearRealmCacheRequest.java index 73595a03412..f1cb6bf8bd0 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/security/action/realm/ClearRealmCacheRequest.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/action/realm/ClearRealmCacheRequest.java @@ -83,17 +83,19 @@ public class ClearRealmCacheRequest extends BaseNodesRequestinternal realm type. + * This excludes the ReservedRealm, as it cannot be configured dynamically. + * @return A map from realm-type to a collection of Setting objects. + */ + public static Map>> getSettings() { + Map>> map = new HashMap<>(); + map.put(FileRealmSettings.TYPE, FileRealmSettings.getSettings()); + map.put(NativeRealmSettings.TYPE, NativeRealmSettings.getSettings()); + map.put(LdapRealmSettings.AD_TYPE, LdapRealmSettings.getSettings(LdapRealmSettings.AD_TYPE)); + map.put(LdapRealmSettings.LDAP_TYPE, LdapRealmSettings.getSettings(LdapRealmSettings.LDAP_TYPE)); + map.put(PkiRealmSettings.TYPE, PkiRealmSettings.getSettings()); + return Collections.unmodifiableMap(map); + } +} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/KeyAndTimestamp.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/KeyAndTimestamp.java new file mode 100644 index 00000000000..6e3286e5f61 --- /dev/null +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/KeyAndTimestamp.java @@ -0,0 +1,63 @@ +/* + * 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; + +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.UnicodeUtil; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.settings.SecureString; + +import java.io.IOException; +import java.util.Arrays; + +public final class KeyAndTimestamp implements Writeable { + private final SecureString key; + private final long timestamp; + + public KeyAndTimestamp(SecureString key, long timestamp) { + this.key = key; + this.timestamp = timestamp; + } + + KeyAndTimestamp(StreamInput input) throws IOException { + timestamp = input.readVLong(); + byte[] keyBytes = input.readByteArray(); + final char[] ref = new char[keyBytes.length]; + int len = UnicodeUtil.UTF8toUTF16(keyBytes, 0, keyBytes.length, ref); + key = new SecureString(Arrays.copyOfRange(ref, 0, len)); + } + + public long getTimestamp() { return timestamp; } + public SecureString getKey() { return key; } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeVLong(timestamp); + BytesRef bytesRef = new BytesRef(key); + out.writeVInt(bytesRef.length); + out.writeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + KeyAndTimestamp that = (KeyAndTimestamp) o; + + if (timestamp != that.timestamp) return false; + return key.equals(that.key); + } + + @Override + public int hashCode() { + int result = key.hashCode(); + result = 31 * result + (int) (timestamp ^ (timestamp >>> 32)); + return result; + } +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java similarity index 96% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java index 352e4255364..f24ce5e574f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/Realm.java @@ -14,8 +14,8 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.xpack.security.user.User; /** - * An authentication mechanism to which the default authentication {@link org.elasticsearch.xpack.security.authc.AuthenticationService - * service } delegates the authentication process. Different realms may be defined, each may be based on different + * An authentication mechanism to which the default authentication org.elasticsearch.xpack.security.authc.AuthenticationService + * delegates the authentication process. Different realms may be defined, each may be based on different * authentication mechanism supporting its own specific authentication token type. */ public abstract class Realm implements Comparable { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/RealmConfig.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/RealmConfig.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/RealmConfig.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/RealmConfig.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java rename to plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java index 619beff9f2c..433567eb915 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/security/authc/RealmSettings.java @@ -40,7 +40,7 @@ import static org.elasticsearch.xpack.security.SecurityField.setting; * with the way we validate settings globally. *

*

- * 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> 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> getIndexTemplateMetaDataUpgrader() { + return templates -> { + for(Plugin p: plugins) { + templates = p.getIndexTemplateMetaDataUpgrader().apply(templates); + } + return templates; + }; + } + + @Override + public Map> getTokenizers() { + Map> tokenizers = new HashMap<>(); + filterPlugins(AnalysisPlugin.class).stream().forEach(p -> tokenizers.putAll(p.getTokenizers())); + return tokenizers; + } + + @Override + public void onIndexModule(IndexModule indexModule) { + super.onIndexModule(indexModule); + filterPlugins(Plugin.class).stream().forEach(p -> p.onIndexModule(indexModule)); + } + + @Override + public Map> getInitialClusterStateCustomSupplier() { + Map> suppliers = new HashMap<>(); + filterPlugins(ClusterPlugin.class).stream().forEach(p -> suppliers.putAll(p.getInitialClusterStateCustomSupplier())); + return suppliers; + } + + @Override + public Function> getFieldFilter() { + List>> items = filterPlugins(MapperPlugin.class).stream().map(p -> + p.getFieldFilter()).collect(Collectors.toList()); + if (items.size() > 1) { + throw new UnsupportedOperationException("Only the security MapperPlugin should override this"); + } else if (items.size() == 1) { + return items.get(0); + } else { + // return the same default from MapperPlugin + return MapperPlugin.NOOP_FIELD_FILTER; + } + } + + @Override + public BiConsumer getJoinValidator() { + // There can be only one. + List> items = filterPlugins(DiscoveryPlugin.class).stream().map(p -> + p.getJoinValidator()).collect(Collectors.toList()); + if (items.size() > 1) { + throw new UnsupportedOperationException("Only the security DiscoveryPlugin should override this"); + } else if (items.size() == 1) { + return items.get(0); + } else { + return null; + } + } + + private List filterPlugins(Class type) { + return plugins.stream().filter(x -> type.isAssignableFrom(x.getClass())).map(p -> ((T)p)) + .collect(Collectors.toList()); + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java b/plugin/core/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java similarity index 89% rename from plugin/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java index 9d0ae4498e5..e0087bea2c5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/TestXPackTransportClient.java @@ -26,6 +26,6 @@ public class TestXPackTransportClient extends TransportClient { } public TestXPackTransportClient(Settings settings, Collection> plugins) { - super(settings, Settings.EMPTY, addPlugins(plugins, XPackPlugin.class, getTestTransportPlugin()), null); + super(settings, Settings.EMPTY, addPlugins(plugins, getTestTransportPlugin()), null); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/XPackSettingsTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/XPackSettingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/XPackSettingsTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/XPackSettingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java b/plugin/core/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java similarity index 70% rename from plugin/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java index 1dfabc3ffd3..8cdf0f611da 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/XPackSingleNodeTestCase.java @@ -7,18 +7,22 @@ package org.elasticsearch.xpack; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESSingleNodeTestCase; -import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; /** * An extention to {@link ESSingleNodeTestCase} that adds node settings specifically needed for x-pack + * + * @deprecated Only use this if you truly need to include ML into your plugin. Now that plugins are split there should be + * no need to test ML alongside your plugin. Just do not include it. */ +@Deprecated public abstract class XPackSingleNodeTestCase extends ESSingleNodeTestCase { @Override protected Settings nodeSettings() { Settings.Builder newSettings = Settings.builder(); // Disable native ML autodetect_process as the c++ controller won't be available - newSettings.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + newSettings.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); return newSettings.build(); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/IteratingActionListenerTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/common/IteratingActionListenerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/common/IteratingActionListenerTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/common/IteratingActionListenerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationChecksTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationChecksTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationChecksTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationChecksTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionRequestTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionRequestTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionResponseTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionResponseTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationInfoActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationIssueTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationIssueTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationIssueTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/deprecation/DeprecationIssueTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java index 5a609eef18a..06dd50f7d1c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java @@ -95,14 +95,15 @@ public class InstallXPackExtensionCommandTests extends ESTestCase { } void assertExtension(String name, Environment env) throws IOException { - Path got = env.pluginsFile().resolve("x-pack").resolve("extensions").resolve(name); + Path got = env.pluginsFile().resolve("x-pack").resolve("x-pack-security").resolve("extensions").resolve(name); assertTrue("dir " + name + " exists", Files.exists(got)); assertTrue("jar was copied", Files.exists(got.resolve("extension.jar"))); assertInstallCleaned(env); } void assertInstallCleaned(Environment env) throws IOException { - try (DirectoryStream stream = Files.newDirectoryStream(env.pluginsFile().resolve("x-pack").resolve("extensions"))) { + try (DirectoryStream stream = Files.newDirectoryStream(env.pluginsFile().resolve("x-pack"). + resolve("x-pack-security").resolve("extensions"))) { for (Path file : stream) { if (file.getFileName().toString().startsWith(".installing")) { fail("Installation dir still exists, " + file); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java index 5971d7604a9..d515a4549f9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java @@ -77,7 +77,7 @@ public class ListXPackExtensionCommandTests extends ESTestCase { } static Path extensionsFile(final Environment env) throws IOException { - return env.pluginsFile().resolve("x-pack").resolve("extensions"); + return env.pluginsFile().resolve("x-pack").resolve("x-pack-security").resolve("extensions"); } static MockTerminal listExtensions(Path home, Environment env) throws Exception { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java index 94cf72017d3..a7fee499cef 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java @@ -33,7 +33,7 @@ public class RemoveXPackExtensionCommandTests extends ESTestCase { } Path createExtensionDir(Environment env) throws IOException { - Path path = env.pluginsFile().resolve("x-pack").resolve("extensions"); + Path path = env.pluginsFile().resolve("x-pack").resolve("x-pack-security").resolve("extensions"); return Files.createDirectories(path); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionInfoTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionInfoTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionInfoTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionInfoTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurityTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurityTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurityTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionSecurityTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionTestUtil.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionTestUtil.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionTestUtil.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionTestUtil.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionsServiceTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionsServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionsServiceTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/extensions/XPackExtensionsServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java b/plugin/core/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/CancelPersistentTaskRequestTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/CancelPersistentTaskRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/CancelPersistentTaskRequestTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/CancelPersistentTaskRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksClusterServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksCustomMetaDataTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorFullRestartIT.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorFullRestartIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorFullRestartIT.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorFullRestartIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorIT.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorIT.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorResponseTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorResponseTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutorResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceStatusTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceStatusTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceStatusTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceStatusTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/RestartPersistentTaskRequestTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/RestartPersistentTaskRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/RestartPersistentTaskRequestTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/RestartPersistentTaskRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/StartPersistentActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/persistent/UpdatePersistentTaskRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java b/plugin/core/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java similarity index 90% rename from plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java index 156376ac755..eb640791a98 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/security/test/SecurityAssertions.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.test; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -21,6 +21,6 @@ public class SecurityAssertions { assertThat(e.status(), is(RestStatus.UNAUTHORIZED)); assertThat(e.getHeaderKeys(), hasSize(1)); assertThat(e.getHeader("WWW-Authenticate"), notNullValue()); - assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + XpackField.SECURITY + "\" charset=\"UTF-8\"")); + assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + XPackField.SECURITY + "\" charset=\"UTF-8\"")); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertUtilsTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/CertUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/CertUtilsTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/CertUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfigTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfigTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustManagerTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustManagerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustManagerTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/RestrictedTrustManagerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloaderTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloaderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloaderTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationReloaderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationSettingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLConfigurationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLServiceTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLServiceTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/SSLServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/StoreKeyConfigTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/StoreKeyConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/StoreKeyConfigTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/StoreKeyConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheckTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheckTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheckTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/TLSLicenseBootstrapCheckTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/TestsSSLService.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/TestsSSLService.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/TestsSSLService.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/TestsSSLService.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/cert/CertificateInfoTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/ssl/cert/CertificateInfoTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/cert/CertificateInfoTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/ssl/cert/CertificateInfoTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/template/TemplateUtilsTests.java b/plugin/core/src/test/java/org/elasticsearch/xpack/template/TemplateUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/template/TemplateUtilsTests.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/template/TemplateUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java b/plugin/core/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java index b104102e1e4..0ae6049308e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java +++ b/plugin/core/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestTestHelper.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ml.MlMetaIndex; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; -import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import java.io.BufferedReader; import java.io.IOException; @@ -61,7 +61,7 @@ public final class XPackRestTestHelper { return false; }); - final List templateNames = Arrays.asList(Auditor.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, + final List templateNames = Arrays.asList(AuditorField.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, AnomalyDetectorsIndex.jobStateIndexName(), AnomalyDetectorsIndex.jobResultsIndexPrefix()); for (String template : templateNames) { ESTestCase.awaitBusy(() -> { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockMock.java b/plugin/core/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockMock.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockMock.java rename to plugin/core/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockMock.java diff --git a/plugin/src/test/resources/monitoring-test.json b/plugin/core/src/test/resources/monitoring-test.json similarity index 100% rename from plugin/src/test/resources/monitoring-test.json rename to plugin/core/src/test/resources/monitoring-test.json diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/complex-x-pack-extension-security.policy b/plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/complex-x-pack-extension-security.policy similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/complex-x-pack-extension-security.policy rename to plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/complex-x-pack-extension-security.policy diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/simple-x-pack-extension-security.policy b/plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/simple-x-pack-extension-security.policy similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/simple-x-pack-extension-security.policy rename to plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/simple-x-pack-extension-security.policy diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/unresolved-x-pack-extension-security.policy b/plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/unresolved-x-pack-extension-security.policy similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/extensions/security/unresolved-x-pack-extension-security.policy rename to plugin/core/src/test/resources/org/elasticsearch/xpack/extensions/security/unresolved-x-pack-extension-security.policy diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openssl_config.cnf diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-cert.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key-noparam.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/prime256v1-key.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-ip-only.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.p12 diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks b/plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks rename to plugin/core/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks diff --git a/plugin/src/test/resources/private.key b/plugin/core/src/test/resources/private.key similarity index 100% rename from plugin/src/test/resources/private.key rename to plugin/core/src/test/resources/private.key diff --git a/plugin/src/test/resources/public.key b/plugin/core/src/test/resources/public.key similarity index 100% rename from plugin/src/test/resources/public.key rename to plugin/core/src/test/resources/public.key diff --git a/plugin/deprecation/build.gradle b/plugin/deprecation/build.gradle new file mode 100644 index 00000000000..614d0ffcd38 --- /dev/null +++ b/plugin/deprecation/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-deprecation' + description 'Elasticsearch Expanded Pack Plugin - Deprecation' + classname 'org.elasticsearch.xpack.deprecation.Deprecation' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} +archivesBaseName = 'x-pack-deprecation' + +// TODO: enable this once we have tests +licenseHeaders.enabled = false + +integTest.enabled = false + +dependencies { + provided "org.elasticsearch:elasticsearch:${version}" + + provided "org.elasticsearch.plugin:x-pack-core:${version}" +} + +dependencyLicenses { + ignoreSha 'x-pack-core' +} + +run { + plugin ':x-pack-elasticsearch:plugin:core' +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java similarity index 92% rename from plugin/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java rename to plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java index 42d2739a46c..4077af89ff7 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java +++ b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/Deprecation.java @@ -15,8 +15,10 @@ import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; +import org.elasticsearch.xpack.XPackClientPlugin; import java.util.Collections; import java.util.List; @@ -25,7 +27,7 @@ import java.util.function.Supplier; /** * The plugin class for the Deprecation API */ -public class Deprecation implements ActionPlugin { +public class Deprecation extends Plugin implements ActionPlugin { @Override public List> getActions() { return Collections.singletonList(new ActionHandler<>(DeprecationInfoAction.INSTANCE, TransportDeprecationInfoAction.class)); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java rename to plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java rename to plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java rename to plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/RestDeprecationInfoAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java rename to plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java index 327e11ce8a8..2a8a310f732 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java +++ b/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportDeprecationInfoAction.java @@ -26,7 +26,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ClientHelper; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; public class TransportDeprecationInfoAction extends TransportMasterNodeReadAction { @@ -92,7 +92,7 @@ public class TransportDeprecationInfoAction extends TransportMasterNodeReadActio client.admin().cluster()::nodesStats); }, listener::onFailure), client.admin().cluster()::nodesInfo); } else { - listener.onFailure(LicenseUtils.newComplianceException(XpackField.DEPRECATION)); + listener.onFailure(LicenseUtils.newComplianceException(XPackField.DEPRECATION)); } } } diff --git a/plugin/deprecation/src/main/plugin-metadata/plugin-security.policy b/plugin/deprecation/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/deprecation/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java rename to plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java diff --git a/plugin/graph/build.gradle b/plugin/graph/build.gradle index 89a7eb776da..cb1dccdaa67 100644 --- a/plugin/graph/build.gradle +++ b/plugin/graph/build.gradle @@ -1,21 +1,32 @@ -apply plugin: 'elasticsearch.build' - +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-graph' + description 'Elasticsearch Expanded Pack Plugin - Graph' + classname 'org.elasticsearch.xpack.graph.Graph' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} archivesBaseName = 'x-pack-graph' // TODO: enable this once we have tests -test.enabled=false licenseHeaders.enabled = false +integTest.enabled = false + dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') } dependencyLicenses { ignoreSha 'x-pack-core' } -parent.bundlePlugin { - from jar +run { + plugin ':x-pack-elasticsearch:plugin:core' } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/graph/Graph.java b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java similarity index 78% rename from plugin/src/main/java/org/elasticsearch/xpack/graph/Graph.java rename to plugin/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java index 8d57057f254..cde71ef912b 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/graph/Graph.java +++ b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/Graph.java @@ -10,22 +10,20 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.inject.Module; -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.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.graph.action.GraphExploreAction; import org.elasticsearch.xpack.graph.action.TransportGraphExploreAction; import org.elasticsearch.xpack.graph.rest.action.RestGraphAction; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -33,14 +31,13 @@ import java.util.function.Supplier; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.elasticsearch.xpack.XpackField.GRAPH; -public class Graph implements ActionPlugin { +public class Graph extends Plugin implements ActionPlugin { public static final String NAME = "graph"; protected final boolean enabled; - - + + public Graph(Settings settings) { this.enabled = XPackSettings.GRAPH_ENABLED.get(settings); } @@ -61,15 +58,12 @@ public class Graph implements ActionPlugin { @Override public List getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings, - IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, - Supplier nodesInCluster) { + IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier nodesInCluster) { if (false == enabled) { return emptyList(); } return singletonList(new RestGraphAction(settings, restController)); } - - public static Collection getNamedWriteables() { - return Arrays.asList(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, GRAPH, GraphFeatureSet.Usage::new)); - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java similarity index 75% rename from plugin/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java rename to plugin/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java index 1d0b896e185..4d842b6ae80 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java +++ b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/GraphFeatureSet.java @@ -5,18 +5,16 @@ */ package org.elasticsearch.xpack.graph; -import java.io.IOException; import java.util.Map; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; public class GraphFeatureSet implements XPackFeatureSet { @@ -31,7 +29,7 @@ public class GraphFeatureSet implements XPackFeatureSet { @Override public String name() { - return XpackField.GRAPH; + return XPackField.GRAPH; } @Override @@ -56,17 +54,7 @@ public class GraphFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { - listener.onResponse(new Usage(available(), enabled())); + listener.onResponse(new GraphFeatureSetUsage(available(), enabled())); } - public static class Usage extends XPackFeatureSet.Usage { - - public Usage(StreamInput input) throws IOException { - super(input); - } - - public Usage(boolean available, boolean enabled) { - super(XpackField.GRAPH, available, enabled); - } - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java rename to plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java index 0fd1b582dff..cba7bfa1bc4 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java +++ b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java @@ -38,7 +38,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilde import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.graph.action.Connection.ConnectionId; import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost; import org.elasticsearch.xpack.graph.action.Vertex.VertexId; @@ -89,7 +89,7 @@ public class TransportGraphExploreAction extends HandledTransportAction> getPlugins() { - return pluginList(ScriptedTimeoutPlugin.class, XPackPlugin.class); + return pluginList(ScriptedTimeoutPlugin.class, Graph.class, XPackPlugin.class); } public void testSignificanceQueryCrawl() { @@ -139,9 +139,9 @@ public class GraphTests extends XPackSingleNodeTestCase { // Disable security otherwise authentication failures happen creating indices. 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.SECURITY_ENABLED.getKey(), false); +// newSettings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); +// newSettings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); return newSettings.build(); } diff --git a/plugin/logstash/build.gradle b/plugin/logstash/build.gradle new file mode 100644 index 00000000000..a4caf28f9d3 --- /dev/null +++ b/plugin/logstash/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-logstash' + description 'Elasticsearch Expanded Pack Plugin - Logstash' + classname 'org.elasticsearch.xpack.logstash.Logstash' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} +archivesBaseName = 'x-pack-logstash' + +// TODO: enable this once we have tests +licenseHeaders.enabled = false + +integTest.enabled = false + +dependencies { + provided "org.elasticsearch:elasticsearch:${version}" + + provided "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + +} + +dependencyLicenses { + ignoreSha 'x-pack-core' +} + +run { + plugin ':x-pack-elasticsearch:plugin:core' +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java b/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java similarity index 89% rename from plugin/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java rename to plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java index 540f5b6d6a1..14f5a1051de 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java +++ b/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java @@ -10,7 +10,10 @@ import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.template.TemplateUtils; @@ -25,7 +28,7 @@ import java.util.regex.Pattern; /** * This class activates/deactivates the logstash modules depending if we're running a node client or transport client */ -public class Logstash implements ActionPlugin { +public class Logstash extends Plugin implements ActionPlugin { public static final String NAME = "logstash"; private static final String LOGSTASH_TEMPLATE_NAME = "logstash-index-template"; @@ -48,7 +51,7 @@ public class Logstash implements ActionPlugin { return transportClientMode; } - public Collection nodeModules() { + public Collection createGuiceModules() { List modules = new ArrayList<>(); modules.add(b -> { XPackPlugin.bindFeatureSet(b, LogstashFeatureSet.class); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java b/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java rename to plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/LogstashFeatureSet.java diff --git a/plugin/logstash/src/main/plugin-metadata/plugin-security.policy b/plugin/logstash/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..9157c2fab47 --- /dev/null +++ b/plugin/logstash/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java b/plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java rename to plugin/logstash/src/test/java/org/elasticsearch/xpack/logstash/LogstashFeatureSetTests.java diff --git a/plugin/ml-cpp-snapshot/build.gradle b/plugin/ml-cpp-snapshot/build.gradle index b12cba40dc8..60500ce7b8b 100644 --- a/plugin/ml-cpp-snapshot/build.gradle +++ b/plugin/ml-cpp-snapshot/build.gradle @@ -125,7 +125,7 @@ void getZip(File snapshotZip) { InputStream zipStream = zip.getObjectContent() try { project.delete(snapshotZip, snapshotZip) - Files.copy(zipStream, snapshotZip.toPath()) + Files.copy(zipStream, snapshotZip.toPath()) } finally { zipStream.close() } diff --git a/plugin/ml/build.gradle b/plugin/ml/build.gradle index 97f6cab3899..bf1b5514f90 100644 --- a/plugin/ml/build.gradle +++ b/plugin/ml/build.gradle @@ -1,27 +1,54 @@ -apply plugin: 'elasticsearch.build' - +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-ml' + description 'Elasticsearch Expanded Pack Plugin - Machine Learning' + classname 'org.elasticsearch.xpack.ml.MachineLearning' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} archivesBaseName = 'x-pack-ml' // TODO: enable this once we have tests -test.enabled=false licenseHeaders.enabled = false +integTest.enabled = false + 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") + substitute module("org.elasticsearch.ml:ml-cpp") with project("${project.parent.path}:ml-cpp-snapshot") } } } } +bundlePlugin { + dependsOn configurations.nativeBundle + 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/**' +} + +compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" +compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" + dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + // This should not be here + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') // ml deps compile 'net.sf.supercsv:super-csv:2.4.0' @@ -33,6 +60,6 @@ dependencyLicenses { ignoreSha 'x-pack-core' } -parent.bundlePlugin { - from jar +run { + plugin ':x-pack-elasticsearch:plugin:core' } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/InvalidLicenseEnforcer.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/InvalidLicenseEnforcer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/InvalidLicenseEnforcer.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/InvalidLicenseEnforcer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java similarity index 88% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 1d0e2ace9ff..691aef78fe8 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -13,15 +13,12 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; -import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.ParseField; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.logging.Loggers; @@ -35,6 +32,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.TokenizerFactory; import org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider; @@ -43,23 +41,21 @@ import org.elasticsearch.monitor.os.OsProbe; import org.elasticsearch.monitor.os.OsStats; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.AnalysisPlugin; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.tasks.Task; +import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.XPackClientActionPlugin; -import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; 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.GetCalendarEventsAction; -import org.elasticsearch.xpack.ml.action.PostCalendarEventsAction; -import org.elasticsearch.xpack.ml.action.TransportDeleteCalendarEventAction; -import org.elasticsearch.xpack.ml.action.UpdateCalendarJobAction; import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction; import org.elasticsearch.xpack.ml.action.DeleteExpiredDataAction; import org.elasticsearch.xpack.ml.action.DeleteFilterAction; @@ -69,6 +65,7 @@ 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; @@ -83,6 +80,7 @@ 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; @@ -94,6 +92,7 @@ import org.elasticsearch.xpack.ml.action.StartDatafeedAction; import org.elasticsearch.xpack.ml.action.StopDatafeedAction; import org.elasticsearch.xpack.ml.action.TransportCloseJobAction; import org.elasticsearch.xpack.ml.action.TransportDeleteCalendarAction; +import org.elasticsearch.xpack.ml.action.TransportDeleteCalendarEventAction; import org.elasticsearch.xpack.ml.action.TransportDeleteDatafeedAction; import org.elasticsearch.xpack.ml.action.TransportDeleteExpiredDataAction; import org.elasticsearch.xpack.ml.action.TransportDeleteFilterAction; @@ -135,6 +134,7 @@ import org.elasticsearch.xpack.ml.action.TransportUpdateModelSnapshotAction; import org.elasticsearch.xpack.ml.action.TransportUpdateProcessAction; import org.elasticsearch.xpack.ml.action.TransportValidateDetectorAction; import org.elasticsearch.xpack.ml.action.TransportValidateJobConfigAction; +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; @@ -143,12 +143,10 @@ import org.elasticsearch.xpack.ml.action.ValidateDetectorAction; import org.elasticsearch.xpack.ml.action.ValidateJobConfigAction; import org.elasticsearch.xpack.ml.datafeed.DatafeedJobBuilder; import org.elasticsearch.xpack.ml.datafeed.DatafeedManager; -import org.elasticsearch.xpack.ml.datafeed.DatafeedState; import org.elasticsearch.xpack.ml.job.JobManager; import org.elasticsearch.xpack.ml.job.UpdateJobProcessNotifier; import org.elasticsearch.xpack.ml.job.categorization.MlClassicTokenizer; import org.elasticsearch.xpack.ml.job.categorization.MlClassicTokenizerFactory; -import org.elasticsearch.xpack.ml.job.config.JobTaskStatus; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.ml.job.persistence.ElasticsearchMappings; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; @@ -168,6 +166,7 @@ import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerProcessFactory; import org.elasticsearch.xpack.ml.notifications.AuditMessage; import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import org.elasticsearch.xpack.ml.rest.RestDeleteExpiredDataAction; import org.elasticsearch.xpack.ml.rest.calendar.RestDeleteCalendarAction; import org.elasticsearch.xpack.ml.rest.calendar.RestDeleteCalendarEventAction; @@ -209,15 +208,20 @@ import org.elasticsearch.xpack.ml.rest.results.RestGetOverallBucketsAction; import org.elasticsearch.xpack.ml.rest.results.RestGetRecordsAction; import org.elasticsearch.xpack.ml.rest.validate.RestValidateDetectorAction; import org.elasticsearch.xpack.ml.rest.validate.RestValidateJobConfigAction; -import org.elasticsearch.xpack.persistent.PersistentTaskParams; -import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; +import org.elasticsearch.xpack.persistent.CompletionPersistentTaskAction; +import org.elasticsearch.xpack.persistent.PersistentTasksClusterService; import org.elasticsearch.xpack.persistent.PersistentTasksExecutor; -import org.elasticsearch.xpack.persistent.PersistentTasksNodeService; +import org.elasticsearch.xpack.persistent.PersistentTasksExecutorRegistry; import org.elasticsearch.xpack.persistent.PersistentTasksService; +import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction; +import org.elasticsearch.xpack.persistent.StartPersistentTaskAction; +import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction; import org.elasticsearch.xpack.template.TemplateUtils; import java.io.IOException; import java.math.BigInteger; +import java.nio.file.Path; +import java.time.Clock; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -228,9 +232,8 @@ import java.util.function.Supplier; import java.util.function.UnaryOperator; import static java.util.Collections.emptyList; -import static org.elasticsearch.xpack.XpackField.MACHINE_LEARNING; -public class MachineLearning implements MachineLearningClientActionPlugin, ActionPlugin, AnalysisPlugin { +public class MachineLearning extends Plugin implements ActionPlugin, AnalysisPlugin { public static final String NAME = "ml"; public static final String BASE_PATH = "/_xpack/ml/"; public static final String DATAFEED_THREAD_POOL_NAME = NAME + "_datafeed"; @@ -241,8 +244,6 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio // Recompile if you want to compare performance with C++ tokenization. public static final boolean CATEGORIZATION_TOKENIZATION_IN_JAVA = true; - public static final Setting AUTODETECT_PROCESS = - Setting.boolSetting("xpack.ml.autodetect_process", true, Property.NodeScope); public static final Setting ML_ENABLED = Setting.boolSetting("node.ml", XPackSettings.MACHINE_LEARNING_ENABLED, Property.NodeScope); public static final String ML_ENABLED_NODE_ATTR = "ml.enabled"; @@ -257,7 +258,6 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio private final Settings settings; private final Environment env; - private final XPackLicenseState licenseState; private final boolean enabled; private final boolean transportClientMode; private final boolean tribeNode; @@ -266,22 +266,24 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio private final SetOnce autodetectProcessManager = new SetOnce<>(); private final SetOnce datafeedManager = new SetOnce<>(); - public MachineLearning(Settings settings, Environment env, XPackLicenseState licenseState) { + public MachineLearning(Settings settings, Path configPath) { this.settings = settings; - this.env = env; - this.licenseState = licenseState; this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); + this.env = transportClientMode ? null : new Environment(settings, configPath); this.tribeNode = XPackClientActionPlugin.isTribeNode(settings); this.tribeNodeClient = XPackClientActionPlugin.isTribeClientNode(settings); } + protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); } + + public List> getSettings() { return Collections.unmodifiableList( - Arrays.asList(AUTODETECT_PROCESS, + Arrays.asList(MachineLearningField.AUTODETECT_PROCESS, ML_ENABLED, CONCURRENT_JOB_ALLOCATIONS, - MAX_MODEL_MEMORY_LIMIT, + MachineLearningField.MAX_MODEL_MEMORY_LIMIT, MAX_MACHINE_MEMORY_PERCENT, ProcessCtrl.DONT_PERSIST_MODEL_STATE_SETTING, ProcessCtrl.MAX_ANOMALY_RECORDS_SETTING, @@ -343,55 +345,44 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio attrName.replace("node.attr.", "xpack.") + "] setting instead."); } - public List getNamedWriteables() { - return Arrays.asList( - // 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), - - // 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), - - // 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), - - // feature set - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, MACHINE_LEARNING, MachineLearningFeatureSet.Usage::new) - ); + // overridable by tests + protected Clock getClock() { + return Clock.systemUTC(); } - public List getNamedXContent() { - return Arrays.asList( - // 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), - // 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), + @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<>(); - // 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) - ); + PersistentTasksService persistentTasksService = new PersistentTasksService(settings, clusterService, threadPool, client); + + components.addAll(createComponents(client, clusterService, threadPool, xContentRegistry, environment, resourceWatcherService, + persistentTasksService)); + + // This was lifted from the XPackPlugins createComponents when it got split + // This is not extensible and anyone copying this code needs to instead make this work + // using the same single service (at the time of this writing XPackPlugin was the place these common things got created) + // and do not just copy this whole thing and drop it in your service. + // The Actions for this service will also have to be moved back into XPackPlugin + List> tasksExecutors = new ArrayList<>(); + tasksExecutors.addAll(createPersistentTasksExecutors(clusterService)); + + PersistentTasksExecutorRegistry registry = new PersistentTasksExecutorRegistry(settings, tasksExecutors); + PersistentTasksClusterService persistentTasksClusterService = new PersistentTasksClusterService(settings, registry, clusterService); + components.add(persistentTasksClusterService); + components.add(persistentTasksService); + components.add(registry); + return components; } public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, - NamedXContentRegistry xContentRegistry, PersistentTasksService persistentTasksService) { + NamedXContentRegistry xContentRegistry, Environment environment, + ResourceWatcherService resourceWatcherService, + PersistentTasksService persistentTasksService) { if (enabled == false || transportClientMode || tribeNode || tribeNodeClient) { return emptyList(); } @@ -406,15 +397,15 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio AutodetectProcessFactory autodetectProcessFactory; NormalizerProcessFactory normalizerProcessFactory; - if (AUTODETECT_PROCESS.get(settings) && MachineLearningFeatureSet.isRunningOnMlPlatform(true)) { + if (MachineLearningField.AUTODETECT_PROCESS.get(settings) && MachineLearningFeatureSet.isRunningOnMlPlatform(true)) { try { - NativeController nativeController = NativeControllerHolder.getNativeController(env); + NativeController nativeController = NativeControllerHolder.getNativeController(environment); if (nativeController == null) { // This will only only happen when path.home is not set, which is disallowed in production throw new ElasticsearchException("Failed to create native process controller for Machine Learning"); } - autodetectProcessFactory = new NativeAutodetectProcessFactory(env, settings, nativeController, client); - normalizerProcessFactory = new NativeNormalizerProcessFactory(env, settings, nativeController); + autodetectProcessFactory = new NativeAutodetectProcessFactory(environment, settings, nativeController, client); + normalizerProcessFactory = new NativeNormalizerProcessFactory(environment, settings, nativeController); } catch (IOException e) { // This also should not happen in production, as the MachineLearningFeatureSet should have // hit the same error first and brought down the node with a friendlier error message @@ -437,9 +428,10 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio DatafeedManager datafeedManager = new DatafeedManager(threadPool, client, clusterService, datafeedJobBuilder, System::currentTimeMillis, auditor, persistentTasksService); this.datafeedManager.set(datafeedManager); - MlLifeCycleService mlLifeCycleService = new MlLifeCycleService(env, clusterService, datafeedManager, autodetectProcessManager); + MlLifeCycleService mlLifeCycleService = new MlLifeCycleService(environment, clusterService, datafeedManager, + autodetectProcessManager); InvalidLicenseEnforcer invalidLicenseEnforcer = - new InvalidLicenseEnforcer(settings, licenseState, threadPool, datafeedManager, autodetectProcessManager); + new InvalidLicenseEnforcer(settings, getLicenseState(), threadPool, datafeedManager, autodetectProcessManager); return Arrays.asList( mlLifeCycleService, @@ -466,7 +458,7 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio ); } - public Collection nodeModules() { + public Collection createGuiceModules() { List modules = new ArrayList<>(); if (tribeNodeClient || transportClientMode) { @@ -582,10 +574,17 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio new ActionHandler<>(DeleteCalendarEventAction.INSTANCE, TransportDeleteCalendarEventAction.class), new ActionHandler<>(UpdateCalendarJobAction.INSTANCE, TransportUpdateCalendarJobAction.class), new ActionHandler<>(GetCalendarEventsAction.INSTANCE, TransportGetCalendarEventsAction.class), - new ActionHandler<>(PostCalendarEventsAction.INSTANCE, TransportPostCalendarEventsAction.class) + new ActionHandler<>(PostCalendarEventsAction.INSTANCE, TransportPostCalendarEventsAction.class), + // These actions reside here because ML is the only user of the Persistence service currently. + // Once another project uses this service, these actions will need to be moved out to a common place + // where they are registered. + new ActionHandler<>(StartPersistentTaskAction.INSTANCE, StartPersistentTaskAction.TransportAction.class), + new ActionHandler<>(UpdatePersistentTaskStatusAction.INSTANCE, UpdatePersistentTaskStatusAction.TransportAction.class), + new ActionHandler<>(RemovePersistentTaskAction.INSTANCE, RemovePersistentTaskAction.TransportAction.class), + new ActionHandler<>(CompletionPersistentTaskAction.INSTANCE, CompletionPersistentTaskAction.TransportAction.class) ); } - + @Override public List> getExecutorBuilders(Settings settings) { if (false == enabled || tribeNode || tribeNodeClient || transportClientMode) { return emptyList(); @@ -614,21 +613,21 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio public Map> getTokenizers() { return Collections.singletonMap(MlClassicTokenizer.NAME, MlClassicTokenizerFactory::new); } - + @Override public UnaryOperator> getIndexTemplateMetaDataUpgrader() { return templates -> { final TimeValue delayedNodeTimeOutSetting; // Whether we are using native process is a good way to detect whether we are in dev / test mode: - if (MachineLearning.AUTODETECT_PROCESS.get(settings)) { + if (MachineLearningField.AUTODETECT_PROCESS.get(settings)) { delayedNodeTimeOutSetting = UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(settings); } else { delayedNodeTimeOutSetting = TimeValue.timeValueNanos(0); } try (XContentBuilder auditMapping = ElasticsearchMappings.auditMessageMapping()) { - IndexTemplateMetaData notificationMessageTemplate = IndexTemplateMetaData.builder(Auditor.NOTIFICATIONS_INDEX) + IndexTemplateMetaData notificationMessageTemplate = IndexTemplateMetaData.builder(AuditorField.NOTIFICATIONS_INDEX) .putMapping(AuditMessage.TYPE.getPreferredName(), auditMapping.string()) - .patterns(Collections.singletonList(Auditor.NOTIFICATIONS_INDEX)) + .patterns(Collections.singletonList(AuditorField.NOTIFICATIONS_INDEX)) .version(Version.CURRENT.id) .settings(Settings.builder() // Our indexes are small and one shard puts the @@ -637,7 +636,7 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio .put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)) .build(); - templates.put(Auditor.NOTIFICATIONS_INDEX, notificationMessageTemplate); + templates.put(AuditorField.NOTIFICATIONS_INDEX, notificationMessageTemplate); } catch (IOException e) { logger.warn("Error loading the template for the notification message index", e); } @@ -704,7 +703,7 @@ public class MachineLearning implements MachineLearningClientActionPlugin, Actio public static boolean allTemplatesInstalled(ClusterState clusterState) { boolean allPresent = true; - List templateNames = Arrays.asList(Auditor.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, + List templateNames = Arrays.asList(AuditorField.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, AnomalyDetectorsIndex.jobStateIndexName(), AnomalyDetectorsIndex.jobResultsIndexPrefix()); for (String templateName : templateNames) { allPresent = allPresent && TemplateUtils.checkTemplateExistsAndVersionIsGTECurrentVersion(templateName, clusterState); diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java new file mode 100644 index 00000000000..6d5f32e06d8 --- /dev/null +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java @@ -0,0 +1,269 @@ +/* + * 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.ml; + +import org.apache.lucene.util.Constants; +import org.apache.lucene.util.Counter; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.action.ActionListener; +import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.env.Environment; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.plugins.Platforms; +import org.elasticsearch.xpack.XPackClientActionPlugin; +import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction; +import org.elasticsearch.xpack.ml.action.GetJobsStatsAction; +import org.elasticsearch.xpack.ml.datafeed.DatafeedState; +import org.elasticsearch.xpack.ml.job.config.Job; +import org.elasticsearch.xpack.ml.job.config.JobState; +import org.elasticsearch.xpack.ml.job.process.NativeController; +import org.elasticsearch.xpack.ml.job.process.NativeControllerHolder; +import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSizeStats; +import org.elasticsearch.xpack.ml.utils.StatsAccumulator; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeoutException; + +public class MachineLearningFeatureSet implements XPackFeatureSet { + + /** + * List of platforms for which the native processes are available + */ + private static final List mlPlatforms = + Arrays.asList("darwin-x86_64", "linux-x86_64", "windows-x86_64"); + + private final boolean enabled; + private final XPackLicenseState licenseState; + private final ClusterService clusterService; + private final Client client; + private final Map nativeCodeInfo; + + @Inject + public MachineLearningFeatureSet(Environment environment, ClusterService clusterService, Client client, + @Nullable XPackLicenseState licenseState) { + this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(environment.settings()); + this.clusterService = Objects.requireNonNull(clusterService); + this.client = Objects.requireNonNull(client); + this.licenseState = licenseState; + Map nativeCodeInfo = NativeController.UNKNOWN_NATIVE_CODE_INFO; + // Don't try to get the native code version if ML is disabled - it causes too much controversy + // if ML has been disabled because of some OS incompatibility. Also don't try to get the native + // code version in the transport or tribe client - the controller process won't be running. + if (enabled && XPackPlugin.transportClientMode(environment.settings()) == false + && XPackClientActionPlugin.isTribeClientNode(environment.settings()) == false) { + try { + if (isRunningOnMlPlatform(true)) { + NativeController nativeController = NativeControllerHolder.getNativeController(environment); + if (nativeController != null) { + nativeCodeInfo = nativeController.getNativeCodeInfo(); + } + } + } catch (IOException | TimeoutException e) { + Loggers.getLogger(MachineLearningFeatureSet.class).error("Cannot get native code info for Machine Learning", e); + throw new ElasticsearchException("Cannot communicate with Machine Learning native code"); + } + } + this.nativeCodeInfo = nativeCodeInfo; + } + + static boolean isRunningOnMlPlatform(boolean fatalIfNot) { + return isRunningOnMlPlatform(Constants.OS_NAME, Constants.OS_ARCH, fatalIfNot); + } + + static boolean isRunningOnMlPlatform(String osName, String osArch, boolean fatalIfNot) { + String platformName = Platforms.platformName(osName, osArch); + if (mlPlatforms.contains(platformName)) { + return true; + } + if (fatalIfNot) { + throw new ElasticsearchException("X-Pack is not supported and Machine Learning is not available for [" + platformName + + "]; you can use the other X-Pack features (unsupported) by setting xpack.ml.enabled: false in elasticsearch.yml"); + } + return false; + } + + @Override + public String name() { + return XPackField.MACHINE_LEARNING; + } + + @Override + public String description() { + return "Machine Learning for the Elastic Stack"; + } + + @Override + public boolean available() { + return licenseState != null && licenseState.isMachineLearningAllowed(); + } + + @Override + public boolean enabled() { + return enabled; + } + + @Override + public Map nativeCodeInfo() { + return nativeCodeInfo; + } + + @Override + public void usage(ActionListener listener) { + ClusterState state = clusterService.state(); + MlMetadata mlMetadata = state.getMetaData().custom(MLMetadataField.TYPE); + + // Handle case when usage is called but MlMetadata has not been installed yet + if (mlMetadata == null) { + listener.onResponse(new MachineLearningFeatureSetUsage(available(), enabled, + Collections.emptyMap(), Collections.emptyMap())); + } else { + new Retriever(client, mlMetadata, available(), enabled()).execute(listener); + } + } + + public static class Retriever { + + private final Client client; + private final MlMetadata mlMetadata; + private final boolean available; + private final boolean enabled; + private Map jobsUsage; + private Map datafeedsUsage; + + public Retriever(Client client, MlMetadata mlMetadata, boolean available, boolean enabled) { + this.client = Objects.requireNonNull(client); + this.mlMetadata = mlMetadata; + this.available = available; + this.enabled = enabled; + this.jobsUsage = new LinkedHashMap<>(); + this.datafeedsUsage = new LinkedHashMap<>(); + } + + public void execute(ActionListener listener) { + if (enabled == false) { + listener.onResponse(new MachineLearningFeatureSetUsage(available, enabled, Collections.emptyMap(), Collections.emptyMap())); + return; + } + + // Step 2. Extract usage from datafeeds stats and return usage response + ActionListener datafeedStatsListener = + ActionListener.wrap(response -> { + addDatafeedsUsage(response); + listener.onResponse(new MachineLearningFeatureSetUsage( + available, enabled, jobsUsage, datafeedsUsage)); + }, + error -> { + listener.onFailure(error); + } + ); + + // Step 1. Extract usage from jobs stats and then request stats for all datafeeds + GetJobsStatsAction.Request jobStatsRequest = new GetJobsStatsAction.Request(MetaData.ALL); + ActionListener jobStatsListener = ActionListener.wrap( + response -> { + addJobsUsage(response); + GetDatafeedsStatsAction.Request datafeedStatsRequest = + new GetDatafeedsStatsAction.Request(GetDatafeedsStatsAction.ALL); + client.execute(GetDatafeedsStatsAction.INSTANCE, datafeedStatsRequest, + datafeedStatsListener); + }, + error -> { + listener.onFailure(error); + } + ); + + // Step 0. Kick off the chain of callbacks by requesting jobs stats + client.execute(GetJobsStatsAction.INSTANCE, jobStatsRequest, jobStatsListener); + } + + private void addJobsUsage(GetJobsStatsAction.Response response) { + StatsAccumulator allJobsDetectorsStats = new StatsAccumulator(); + StatsAccumulator allJobsModelSizeStats = new StatsAccumulator(); + + Map jobCountByState = new HashMap<>(); + Map detectorStatsByState = new HashMap<>(); + Map modelSizeStatsByState = new HashMap<>(); + + Map jobs = mlMetadata.getJobs(); + List jobsStats = response.getResponse().results(); + for (GetJobsStatsAction.Response.JobStats jobStats : jobsStats) { + ModelSizeStats modelSizeStats = jobStats.getModelSizeStats(); + int detectorsCount = jobs.get(jobStats.getJobId()).getAnalysisConfig() + .getDetectors().size(); + double modelSize = modelSizeStats == null ? 0.0 + : jobStats.getModelSizeStats().getModelBytes(); + + allJobsDetectorsStats.add(detectorsCount); + allJobsModelSizeStats.add(modelSize); + + JobState jobState = jobStats.getState(); + jobCountByState.computeIfAbsent(jobState, js -> Counter.newCounter()).addAndGet(1); + detectorStatsByState.computeIfAbsent(jobState, + js -> new StatsAccumulator()).add(detectorsCount); + modelSizeStatsByState.computeIfAbsent(jobState, + js -> new StatsAccumulator()).add(modelSize); + } + + jobsUsage.put(MachineLearningFeatureSetUsage.ALL, createJobUsageEntry(jobs.size(), allJobsDetectorsStats, + allJobsModelSizeStats)); + for (JobState jobState : jobCountByState.keySet()) { + jobsUsage.put(jobState.name().toLowerCase(Locale.ROOT), createJobUsageEntry( + jobCountByState.get(jobState).get(), + detectorStatsByState.get(jobState), + modelSizeStatsByState.get(jobState))); + } + } + + private Map createJobUsageEntry(long count, StatsAccumulator detectorStats, + StatsAccumulator modelSizeStats) { + Map usage = new HashMap<>(); + usage.put(MachineLearningFeatureSetUsage.COUNT, count); + usage.put(MachineLearningFeatureSetUsage.DETECTORS, detectorStats.asMap()); + usage.put(MachineLearningFeatureSetUsage.MODEL_SIZE, modelSizeStats.asMap()); + return usage; + } + + private void addDatafeedsUsage(GetDatafeedsStatsAction.Response response) { + Map datafeedCountByState = new HashMap<>(); + + List datafeedsStats = response.getResponse().results(); + for (GetDatafeedsStatsAction.Response.DatafeedStats datafeedStats : datafeedsStats) { + datafeedCountByState.computeIfAbsent(datafeedStats.getDatafeedState(), + ds -> Counter.newCounter()).addAndGet(1); + } + + datafeedsUsage.put(MachineLearningFeatureSetUsage.ALL, createDatafeedUsageEntry(response.getResponse().count())); + for (DatafeedState datafeedState : datafeedCountByState.keySet()) { + datafeedsUsage.put(datafeedState.name().toLowerCase(Locale.ROOT), + createDatafeedUsageEntry(datafeedCountByState.get(datafeedState).get())); + } + } + + private Map createDatafeedUsageEntry(long count) { + Map usage = new HashMap<>(); + usage.put(MachineLearningFeatureSetUsage.COUNT, count); + return usage; + } + } +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceService.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceService.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlDailyMaintenanceService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlLifeCycleService.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlLifeCycleService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/MlLifeCycleService.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlLifeCycleService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteExpiredDataAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteExpiredDataAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteExpiredDataAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteExpiredDataAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteFilterAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteFilterAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteFilterAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteFilterAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java index 159c720a3d3..bee1e26cf69 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java @@ -28,7 +28,7 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ml.MLMetadataField; -import org.elasticsearch.xpack.ml.MachineLearningClientActionPlugin; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.job.JobManager; import org.elasticsearch.xpack.ml.job.persistence.JobStorageDeletionTask; @@ -88,7 +88,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteModelSnapshotAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteModelSnapshotAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteModelSnapshotAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteModelSnapshotAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportFlushJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFlushJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportFlushJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFlushJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportForecastJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportForecastJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportForecastJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportForecastJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetBucketsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetBucketsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetBucketsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetBucketsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarEventsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarEventsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarEventsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarEventsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCalendarsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCategoriesAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCategoriesAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCategoriesAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetCategoriesAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsStatsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsStatsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetDatafeedsStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetFiltersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetInfluencersAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetInfluencersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetInfluencersAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetInfluencersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetModelSnapshotsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetModelSnapshotsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetModelSnapshotsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetModelSnapshotsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetOverallBucketsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetOverallBucketsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetOverallBucketsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetOverallBucketsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetRecordsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetRecordsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetRecordsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetRecordsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportIsolateDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportIsolateDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportIsolateDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportIsolateDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportKillProcessAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportKillProcessAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportKillProcessAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportKillProcessAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java index a31c89858c3..25f6c1160e4 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java @@ -42,7 +42,7 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.ml.MLMetadataField; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MlMetaIndex; @@ -455,7 +455,7 @@ public class TransportOpenJobAction extends TransportMasterNodeAction { @@ -69,7 +68,7 @@ public class TransportPutJobAction extends TransportMasterNodeAction() { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/RestDeleteExpiredDataAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/RestDeleteExpiredDataAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/RestDeleteExpiredDataAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/RestDeleteExpiredDataAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarEventAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarEventAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarEventAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarEventAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestDeleteCalendarJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarEventsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarEventsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarEventsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarEventsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestGetCalendarsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPostCalendarEventAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPostCalendarEventAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPostCalendarEventAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPostCalendarEventAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/calendar/RestPutCalendarJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestDeleteDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestDeleteDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestDeleteDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestDeleteDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestGetDatafeedsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPreviewDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPreviewDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPreviewDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPreviewDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPutDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPutDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPutDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestPutDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStopDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStopDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStopDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStopDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestUpdateDatafeedAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestUpdateDatafeedAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestUpdateDatafeedAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestUpdateDatafeedAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestDeleteFilterAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestDeleteFilterAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestDeleteFilterAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestDeleteFilterAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestGetFiltersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestPutFilterAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestPutFilterAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestPutFilterAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/filter/RestPutFilterAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestCloseJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestCloseJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestCloseJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestCloseJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestDeleteJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestFlushJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestFlushJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestFlushJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestFlushJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestForecastJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestForecastJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestForecastJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestForecastJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestGetJobsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostJobUpdateAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostJobUpdateAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostJobUpdateAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostJobUpdateAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPutJobAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPutJobAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPutJobAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPutJobAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestDeleteModelSnapshotAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestDeleteModelSnapshotAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestDeleteModelSnapshotAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestDeleteModelSnapshotAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestGetModelSnapshotsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestRevertModelSnapshotAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestRevertModelSnapshotAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestRevertModelSnapshotAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestRevertModelSnapshotAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestUpdateModelSnapshotAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestUpdateModelSnapshotAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestUpdateModelSnapshotAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/modelsnapshots/RestUpdateModelSnapshotAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetBucketsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetCategoriesAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetInfluencersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetOverallBucketsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/results/RestGetRecordsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateDetectorAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateDetectorAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateDetectorAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateDetectorAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateJobConfigAction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateJobConfigAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateJobConfigAction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/validate/RestValidateJobConfigAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelper.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelper.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelper.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelper.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/StatsAccumulator.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/StatsAccumulator.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/utils/StatsAccumulator.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/StatsAccumulator.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/VolatileCursorIterator.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/VolatileCursorIterator.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/ml/utils/VolatileCursorIterator.java rename to plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/VolatileCursorIterator.java diff --git a/plugin/ml/src/main/plugin-metadata/plugin-security.policy b/plugin/ml/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/ml/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/main/resources/org/elasticsearch/xpack/ml/transforms/exact.properties b/plugin/ml/src/main/resources/org/elasticsearch/xpack/ml/transforms/exact.properties similarity index 100% rename from plugin/src/main/resources/org/elasticsearch/xpack/ml/transforms/exact.properties rename to plugin/ml/src/main/resources/org/elasticsearch/xpack/ml/transforms/exact.properties diff --git a/plugin/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java b/plugin/ml/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java rename to plugin/ml/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java index df40f6604a6..abc3cbd45b9 100644 --- a/plugin/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/license/MachineLearningLicensingTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.license.License.OperationMode; @@ -16,7 +17,8 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.ml.LocalStateMachineLearning; import org.elasticsearch.xpack.ml.action.CloseJobAction; import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction; import org.elasticsearch.xpack.ml.action.DeleteJobAction; @@ -58,7 +60,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(false); // test that license restricted apis do not work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture. newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), listener); @@ -67,7 +70,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { } catch (ElasticsearchSecurityException e) { assertThat(e.status(), is(RestStatus.FORBIDDEN)); assertThat(e.getMessage(), containsString("non-compliant")); - assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XpackField.MACHINE_LEARNING)); + assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.MACHINE_LEARNING)); } // Pick a license that does allow machine learning @@ -75,7 +78,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), listener); @@ -88,7 +91,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String jobId = "testmachinelearningopenjobactionrestricted"; assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -101,7 +105,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(false); // test that license restricted apis do not work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).openJob(new OpenJobAction.Request(jobId), listener); @@ -110,7 +114,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { } catch (ElasticsearchSecurityException e) { assertThat(e.status(), is(RestStatus.FORBIDDEN)); assertThat(e.getMessage(), containsString("non-compliant")); - assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XpackField.MACHINE_LEARNING)); + assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.MACHINE_LEARNING)); } // Pick a license that does allow machine learning @@ -125,7 +129,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { }); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).openJob(new OpenJobAction.Request(jobId), listener); @@ -139,7 +143,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String datafeedId = jobId + "-datafeed"; assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -152,7 +157,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(false); // test that license restricted apis do not work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putDatafeed( @@ -162,7 +167,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { } catch (ElasticsearchSecurityException e) { assertThat(e.status(), is(RestStatus.FORBIDDEN)); assertThat(e.getMessage(), containsString("non-compliant")); - assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XpackField.MACHINE_LEARNING)); + assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.MACHINE_LEARNING)); } // Pick a license that does allow machine learning @@ -170,7 +175,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putDatafeed( @@ -185,9 +190,10 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String datafeedId = jobId + "-datafeed"; assertMLAllowed(true); String datafeedIndex = jobId + "-data"; - prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", XContentType.JSON) - .get(); - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", + XContentType.JSON).get(); + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); // put job PlainActionFuture putJobListener = PlainActionFuture.newFuture(); @@ -235,7 +241,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(randomValidLicenseType()); assertMLAllowed(true); - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); // open job PlainActionFuture openJobListener = PlainActionFuture.newFuture(); @@ -286,10 +292,11 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String datafeedId = jobId + "-datafeed"; assertMLAllowed(true); String datafeedIndex = jobId + "-data"; - prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", XContentType.JSON) - .get(); + prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", + XContentType.JSON).get(); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -322,7 +329,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { }); // test that license restricted apis do not work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request(datafeedId, 0L), listener); @@ -331,7 +338,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { } catch (ElasticsearchSecurityException e) { assertThat(e.status(), is(RestStatus.FORBIDDEN)); assertThat(e.getMessage(), containsString("non-compliant")); - assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XpackField.MACHINE_LEARNING)); + assertThat(e.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.MACHINE_LEARNING)); } // Pick a license that does allow machine learning @@ -339,7 +346,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(mode); assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); // re-open job now that the license is valid again PlainActionFuture openJobListener = PlainActionFuture.newFuture(); @@ -359,10 +366,11 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String datafeedId = jobId + "-datafeed"; assertMLAllowed(true); String datafeedIndex = jobId + "-data"; - prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", XContentType.JSON) - .get(); + prepareCreate(datafeedIndex).addMapping("type", "{\"type\":{\"properties\":{\"time\":{\"type\":\"date\"}}}}", + XContentType.JSON).get(); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -379,7 +387,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { OpenJobAction.Response openJobResponse = openJobListener.actionGet(); assertNotNull(openJobResponse); PlainActionFuture startDatafeedListener = PlainActionFuture.newFuture(); - new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request(datafeedId, 0L), startDatafeedListener); + new MachineLearningClient(client).startDatafeed( + new StartDatafeedAction.Request(datafeedId, 0L), startDatafeedListener); StartDatafeedAction.Response startDatafeedResponse = startDatafeedListener.actionGet(); assertNotNull(startDatafeedResponse); } @@ -391,7 +400,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(randomValidLicenseType()); } - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).stopDatafeed(new StopDatafeedAction.Request(datafeedId), listener); @@ -422,7 +431,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String jobId = "testmachinelearningclosejobactionnotrestricted"; assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -441,7 +451,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { enableLicensing(randomValidLicenseType()); } - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); CloseJobAction.Request request = new CloseJobAction.Request(jobId); @@ -464,7 +474,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String jobId = "testmachinelearningclosejobactionnotrestricted"; assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -476,7 +487,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { License.OperationMode mode = randomLicenseType(); enableLicensing(mode); - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).deleteJob(new DeleteJobAction.Request(jobId), listener); @@ -489,7 +500,8 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { String datafeedId = jobId + "-datafeed"; assertMLAllowed(true); // test that license restricted apis do now work - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture putJobListener = PlainActionFuture.newFuture(); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob(jobId)), putJobListener); @@ -507,7 +519,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase { License.OperationMode mode = randomLicenseType(); enableLicensing(mode); - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateMachineLearning.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); PlainActionFuture listener = PlainActionFuture.newFuture(); new MachineLearningClient(client).deleteDatafeed(new DeleteDatafeedAction.Request(datafeedId), listener); diff --git a/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/LocalStateMachineLearning.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/LocalStateMachineLearning.java new file mode 100644 index 00000000000..756c95bcae7 --- /dev/null +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/LocalStateMachineLearning.java @@ -0,0 +1,67 @@ +/* + * 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.ml; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.LicenseService; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; + +import java.nio.file.Path; + +public class LocalStateMachineLearning extends LocalStateCompositeXPackPlugin { + + public LocalStateMachineLearning(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + LocalStateMachineLearning thisVar = this; + + plugins.add(new MachineLearning(settings, configPath){ + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Monitoring(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected LicenseService getLicenseService() { + return thisVar.getLicenseService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Security(settings, configPath) { + @Override + protected SSLService getSslService() { return thisVar.getSslService(); } + + @Override + protected XPackLicenseState getLicenseState() { return thisVar.getLicenseState(); } + }); + } +} + diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java index 35a35d038c2..3a150895e72 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSetTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackFeatureSet.Usage; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction; import org.elasticsearch.xpack.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.ml.action.util.QueryPage; @@ -64,7 +64,7 @@ public class MachineLearningFeatureSetTests extends ESTestCase { public void init() throws Exception { commonSettings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath()) - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) + .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .build(); clusterService = mock(ClusterService.class); client = mock(Client.class); @@ -101,7 +101,7 @@ public class MachineLearningFeatureSetTests extends ESTestCase { BytesStreamOutput out = new BytesStreamOutput(); usage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSetUsage(out.bytes().streamInput()); assertThat(serializedUsage.available(), is(available)); } @@ -124,7 +124,7 @@ public class MachineLearningFeatureSetTests extends ESTestCase { BytesStreamOutput out = new BytesStreamOutput(); usage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSetUsage(out.bytes().streamInput()); assertThat(serializedUsage.enabled(), is(expected)); } @@ -156,11 +156,11 @@ public class MachineLearningFeatureSetTests extends ESTestCase { BytesStreamOutput out = new BytesStreamOutput(); mlUsage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSetUsage(out.bytes().streamInput()); for (XPackFeatureSet.Usage usage : Arrays.asList(mlUsage, serializedUsage)) { assertThat(usage, is(notNullValue())); - assertThat(usage.name(), is(XpackField.MACHINE_LEARNING)); + assertThat(usage.name(), is(XPackField.MACHINE_LEARNING)); assertThat(usage.enabled(), is(true)); assertThat(usage.available(), is(true)); XContentSource source; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java index 0126114f1dc..9b141380c65 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningTests.java @@ -30,7 +30,7 @@ public class MachineLearningTests extends ESTestCase { } builder.put("node.attr.foo", "abc"); builder.put("node.attr.ml.bar", "def"); - MachineLearning machineLearning = createMachineLearning(builder.build()); + MachineLearning machineLearning = createMachineLearning(builder.put("path.home", createTempDir()).build()); assertNotNull(machineLearning.additionalSettings()); } @@ -45,7 +45,7 @@ public class MachineLearningTests extends ESTestCase { builder.put("xpack.ml.max_open_jobs", maxOpenJobs); builder.put("node.attr.ml.max_open_jobs", maxOpenJobs); } - MachineLearning machineLearning = createMachineLearning(builder.build()); + MachineLearning machineLearning = createMachineLearning(builder.put("path.home", createTempDir()).build()); assertNotNull(machineLearning.additionalSettings()); } @@ -64,7 +64,7 @@ public class MachineLearningTests extends ESTestCase { } else { builder.put("node.attr.ml.max_open_jobs", randomIntBetween(13, 15)); } - MachineLearning machineLearning = createMachineLearning(builder.build()); + MachineLearning machineLearning = createMachineLearning(builder.put("path.home", createTempDir()).build()); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, machineLearning::additionalSettings); assertThat(e.getMessage(), startsWith("Directly setting [node.attr.ml.")); assertThat(e.getMessage(), containsString("] is not permitted - " + @@ -108,6 +108,13 @@ public class MachineLearningTests extends ESTestCase { } private MachineLearning createMachineLearning(Settings settings) { - return new MachineLearning(settings, mock(Environment.class), mock(XPackLicenseState.class)); + XPackLicenseState licenseState = mock(XPackLicenseState.class); + + return new MachineLearning(settings, null){ + @Override + protected XPackLicenseState getLicenseState() { + return licenseState; + } + }; } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlAssignmentNotifierTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlAssignmentNotifierTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MlAssignmentNotifierTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlAssignmentNotifierTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlClientHelperTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlClientHelperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MlClientHelperTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlClientHelperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlDailyManagementServiceTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlDailyManagementServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MlDailyManagementServiceTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlDailyManagementServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlInitializationServiceTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlInitializationServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MlInitializationServiceTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlInitializationServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/CloseJobActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteCalendarEventActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteCalendarEventActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteCalendarEventActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteCalendarEventActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteDatafeedRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteExpiredDataActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteExpiredDataActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteExpiredDataActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteExpiredDataActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/DeleteJobRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ForecastJobActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetBucketActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarEventsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCalendarsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetCategoriesResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedStatsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetDatafeedsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetFiltersActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetInfluencersActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobStatsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsStatsActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsStatsActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsStatsActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsStatsActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetModelSnapshotsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetOverallBucketsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/GetRecordsActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java index 05547100e86..ca0cfebcbae 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/OpenJobActionTests.java @@ -40,7 +40,7 @@ import org.elasticsearch.xpack.ml.job.config.JobTaskStatus; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndexFields; import org.elasticsearch.xpack.ml.job.persistence.ElasticsearchMappings; -import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Assignment; @@ -481,7 +481,7 @@ public class OpenJobActionTests extends ESTestCase { List indices = new ArrayList<>(); indices.add(AnomalyDetectorsIndex.jobStateIndexName()); indices.add(MlMetaIndex.INDEX_NAME); - indices.add(Auditor.NOTIFICATIONS_INDEX); + indices.add(AuditorField.NOTIFICATIONS_INDEX); indices.add(AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT); for (String indexName : indices) { IndexMetaData.Builder indexMetaData = IndexMetaData.builder(indexName); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostCalendarEventActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostCalendarEventActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostCalendarEventActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostCalendarEventActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PostDataFlushResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PreviewDatafeedActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutCalendarActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutFilterActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutFilterActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutFilterActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutFilterActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/PutJobActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/RevertModelSnapshotActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StopDatafeedActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StopDatafeedActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/StopDatafeedActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/StopDatafeedActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateCalendarJobActionResquestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateCalendarJobActionResquestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateCalendarJobActionResquestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateCalendarJobActionResquestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateDatafeedActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateJobActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateJobActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateJobActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateJobActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionResponseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionResponseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateModelSnapshotActionResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ValidateDetectorActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateJobConfigActionRequestTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ValidateJobConfigActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/ValidateJobConfigActionRequestTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/ValidateJobConfigActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/PageParamsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/util/PageParamsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/PageParamsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/util/PageParamsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/util/QueryPageTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/calendars/CalendarTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/calendars/CalendarTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/calendars/CalendarTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/calendars/CalendarTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/calendars/ScheduledEventTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/calendars/ScheduledEventTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/calendars/ScheduledEventTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/calendars/ScheduledEventTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/ChunkingConfigTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/ChunkingConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/ChunkingConfigTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/ChunkingConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobValidatorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobValidatorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobValidatorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobValidatorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java index 2f54bc24fbf..8322d951fa8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManagerTests.java @@ -38,6 +38,7 @@ import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.persistence.MockClientBuilder; import org.elasticsearch.xpack.ml.notifications.AuditMessage; import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.PersistentTask; import org.elasticsearch.xpack.persistent.PersistentTasksService; @@ -102,7 +103,7 @@ public class DatafeedManagerTests extends ESTestCase { ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(XContentBuilder.class); Client client = new MockClientBuilder("foo") - .prepareIndex(Auditor.NOTIFICATIONS_INDEX, AuditMessage.TYPE.getPreferredName(), "responseId", argumentCaptor) + .prepareIndex(AuditorField.NOTIFICATIONS_INDEX, AuditMessage.TYPE.getPreferredName(), "responseId", argumentCaptor) .build(); DiscoveryNode dNode = mock(DiscoveryNode.class); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelectorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelectorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelectorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelectorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedStateTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedStateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedStateTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedStateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/ProblemTrackerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/ProblemTrackerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/ProblemTrackerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/ProblemTrackerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/ExtractorUtilsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/ExtractorUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/ExtractorUtilsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/ExtractorUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactoryTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactoryTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationTestUtils.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationTestUtils.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationTestUtils.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationTestUtils.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationToJsonProcessorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactoryTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactoryTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ExtractedFieldsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/SearchHitToJsonProcessorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectMemoryLimitIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectMemoryLimitIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectMemoryLimitIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectMemoryLimitIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java index 05475e7b9ab..fa861cfcca3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java @@ -16,6 +16,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.XPackSingleNodeTestCase; +import org.elasticsearch.xpack.ml.LocalStateMachineLearning; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.action.DeleteJobAction; import org.elasticsearch.xpack.ml.action.PutJobAction; @@ -89,7 +90,7 @@ public class AutodetectResultProcessorIT extends XPackSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(XPackPlugin.class, ReindexPlugin.class); + return pluginList(LocalStateMachineLearning.class, ReindexPlugin.class); } @Before diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/BasicRenormalizationIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicRenormalizationIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/BasicRenormalizationIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicRenormalizationIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java index 319ca213193..afa34bc22d8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java @@ -13,10 +13,10 @@ import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import org.elasticsearch.xpack.test.rest.XPackRestTestHelper; import org.junit.After; import org.junit.Before; @@ -39,11 +39,11 @@ import static org.hamcrest.Matchers.equalTo; public class DatafeedJobsRestIT extends ESRestTestCase { private static final String BASIC_AUTH_VALUE_SUPER_USER = - basicAuthHeaderValue("x_pack_rest_user", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + basicAuthHeaderValue("x_pack_rest_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); private static final String BASIC_AUTH_VALUE_ML_ADMIN = - basicAuthHeaderValue("ml_admin", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + basicAuthHeaderValue("ml_admin", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); private static final String BASIC_AUTH_VALUE_ML_ADMIN_WITH_SOME_DATA_ACCESS = - basicAuthHeaderValue("ml_admin_plus_data", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + basicAuthHeaderValue("ml_admin_plus_data", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); @Override protected Settings restClientSettings() { @@ -67,7 +67,7 @@ public class DatafeedJobsRestIT extends ESRestTestCase { } private void setupUser(String user, List roles) throws IOException { - String password = new String(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING.getChars()); + String password = new String(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING.getChars()); String json = "{" + " \"password\" : \"" + password + "\"," @@ -552,7 +552,7 @@ public class DatafeedJobsRestIT extends ESRestTestCase { // There should be a notification saying that there was a problem extracting data client().performRequest("post", "_refresh"); - Response notificationsResponse = client().performRequest("get", Auditor.NOTIFICATIONS_INDEX + "/_search?q=job_id:" + jobId); + Response notificationsResponse = client().performRequest("get", AuditorField.NOTIFICATIONS_INDEX + "/_search?q=job_id:" + jobId); String notificationsResponseAsString = responseEntityToString(notificationsResponse); assertThat(notificationsResponseAsString, containsString("\"message\":\"Datafeed is encountering errors extracting data: " + "action [indices:data/read/search] is unauthorized for user [ml_admin_plus_data]\"")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteJobIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteJobIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteJobIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteJobIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DetectionRulesIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DetectionRulesIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DetectionRulesIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/DetectionRulesIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/EstablishedMemUsageIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/InterimResultsDeletedAfterReopeningJobIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/InterimResultsDeletedAfterReopeningJobIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/InterimResultsDeletedAfterReopeningJobIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/InterimResultsDeletedAfterReopeningJobIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java index 08a8553b89c..2d7c379bec8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobProviderIT.java @@ -22,6 +22,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.XPackSingleNodeTestCase; +import org.elasticsearch.xpack.ml.LocalStateMachineLearning; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MlMetaIndex; import org.elasticsearch.xpack.ml.action.PutJobAction; @@ -91,7 +92,7 @@ public class JobProviderIT extends XPackSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(XPackPlugin.class); + return pluginList(LocalStateMachineLearning.class); } @Before diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobStorageDeletionTaskIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java index 6207fecb04c..1e45868a30c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java @@ -13,7 +13,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.ConcurrentMapLong; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.not; public class MlJobIT extends ESRestTestCase { private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("x_pack_rest_user", - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); @Override protected Settings restClientSettings() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java index c5606138d80..c2ef5ad87c1 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.tasks.Task; import org.elasticsearch.test.SecurityIntegTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.action.CloseJobAction; @@ -71,7 +71,7 @@ import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.persistent.PersistentTaskParams; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.persistent.PersistentTasksNodeService; -import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.authc.TokenMetaData; import java.io.IOException; @@ -106,8 +106,8 @@ abstract class MlNativeAutodetectIntegTestCase extends SecurityIntegTestCase { throw new IllegalStateException("error trying to get keystore path", e); } Settings.Builder builder = Settings.builder(); - builder.put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4); - builder.put(Security.USER_SETTING.getKey(), "x_pack_rest_user:" + SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4); + builder.put(SecurityField.USER_SETTING.getKey(), "x_pack_rest_user:" + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); builder.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), true); builder.put("xpack.security.transport.ssl.enabled", true); builder.put("xpack.security.transport.ssl.keystore.path", keyStore.toAbsolutePath().toString()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/NetworkDisruptionIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/OverallBucketsIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/OverallBucketsIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/OverallBucketsIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/OverallBucketsIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/RestoreModelSnapshotIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/RestoreModelSnapshotIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/RestoreModelSnapshotIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/RestoreModelSnapshotIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/RevertModelSnapshotIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/UpdateInterimResultsIT.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/UpdateInterimResultsIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/integration/UpdateInterimResultsIT.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/UpdateInterimResultsIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java index 559fe9592d1..b3fb3910558 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/JobManagerTests.java @@ -21,7 +21,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ml.MLMetadataField; -import org.elasticsearch.xpack.ml.MachineLearningClientActionPlugin; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.action.PutJobAction; import org.elasticsearch.xpack.ml.action.util.QueryPage; @@ -319,7 +319,7 @@ public class JobManagerTests extends ESTestCase { private JobManager createJobManager() { ClusterSettings clusterSettings = new ClusterSettings(environment.settings(), - Collections.singleton(MachineLearningClientActionPlugin.MAX_MODEL_MEMORY_LIMIT)); + Collections.singleton(MachineLearningField.MAX_MODEL_MEMORY_LIMIT)); when(clusterService.getClusterSettings()).thenReturn(clusterSettings); return new JobManager(environment, environment.settings(), jobProvider, clusterService, auditor, client, updateJobProcessNotifier); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java index bd195808475..cc3a1372f17 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/categorization/CategorizationAnalyzerTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.job.config.CategorizationAnalyzerConfig; import org.junit.Before; @@ -30,8 +31,8 @@ public class CategorizationAnalyzerTests extends ESTestCase { public static AnalysisRegistry buildTestAnalysisRegistry(Environment environment) throws Exception { CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin(); - XPackPlugin xPackPlugin = new XPackPlugin(environment.settings(), environment.configFile()); - return new AnalysisModule(environment, Arrays.asList(commonAnalysisPlugin, xPackPlugin)).getAnalysisRegistry(); + MachineLearning ml = new MachineLearning(environment.settings(), environment.configFile()); + return new AnalysisModule(environment, Arrays.asList(commonAnalysisPlugin, ml)).getAnalysisRegistry(); } @Before diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/categorization/MlClassicTokenizerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisConfigTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisConfigTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisLimitsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisLimitsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisLimitsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/AnalysisLimitsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/CategorizationAnalyzerConfigTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/CategorizationAnalyzerConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/CategorizationAnalyzerConfigTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/CategorizationAnalyzerConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ConditionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ConditionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ConnectiveTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ConnectiveTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ConnectiveTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ConnectiveTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DataDescriptionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataFormatTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DataFormatTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DataFormatTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DataFormatTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DefaultDetectorDescriptionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DefaultDetectorDescriptionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DefaultDetectorDescriptionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DefaultDetectorDescriptionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectionRuleTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectionRuleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectionRuleTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectionRuleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/DetectorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobStateTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobStateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobStateTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobStateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTaskStatusTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTaskStatusTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTaskStatusTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTaskStatusTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java index 4db9192e53e..be2be4e4233 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java @@ -19,7 +19,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.AbstractSerializingTestCase; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.ml.MachineLearningClientActionPlugin; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.ml.job.messages.Messages; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndexFields; import org.elasticsearch.xpack.ml.job.process.autodetect.state.DataCounts; @@ -146,7 +146,7 @@ public class JobTests extends AbstractSerializingTestCase { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> builder.validateModelMemoryLimit(new ByteSizeValue(1000L, ByteSizeUnit.MB))); assertEquals("model_memory_limit [4gb] must be less than the value of the " + - MachineLearningClientActionPlugin.MAX_MODEL_MEMORY_LIMIT.getKey() + " setting [1000mb]", e.getMessage()); + MachineLearningField.MAX_MODEL_MEMORY_LIMIT.getKey() + " setting [1000mb]", e.getMessage()); builder.validateModelMemoryLimit(new ByteSizeValue(8192L, ByteSizeUnit.MB)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/JobUpdateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/MlFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/ModelPlotConfigTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/OperatorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/OperatorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/OperatorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/OperatorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTypeTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTypeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTypeTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/config/RuleConditionTypeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobLookupTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobLookupTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobLookupTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobLookupTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/groups/GroupOrJobTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/messages/MessagesTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/messages/MessagesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/messages/MessagesTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/messages/MessagesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/BatchedDocumentsIteratorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/BatchedDocumentsIteratorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/BatchedDocumentsIteratorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/BatchedDocumentsIteratorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappingsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappingsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ElasticsearchMappingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/InfluencersQueryBuilderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/InfluencersQueryBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/InfluencersQueryBuilderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/InfluencersQueryBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobProviderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobProviderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobProviderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobProviderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersisterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersisterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersisterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobRenormalizedResultsPersisterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockBatchedDocumentsIterator.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockBatchedDocumentsIterator.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockBatchedDocumentsIterator.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockBatchedDocumentsIterator.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ResultsFilterBuilderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ResultsFilterBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ResultsFilterBuilderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/ResultsFilterBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/StateStreamerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregatorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregatorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregatorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsAggregatorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollectorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollectorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollectorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsCollectorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProviderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProviderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProviderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/overallbuckets/OverallBucketsProviderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/CountingInputStreamTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/CountingInputStreamTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/CountingInputStreamTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/CountingInputStreamTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DataCountsReporterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnosticsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnosticsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnosticsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DataStreamDiagnosticsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DummyDataCountsReporter.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DummyDataCountsReporter.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/DummyDataCountsReporter.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/DummyDataCountsReporter.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/NativeControllerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/NativeControllerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/NativeControllerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/NativeControllerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessPipesTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessPipesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessPipesTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessPipesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectCommunicatorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcessTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcessTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcessTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/BlackHoleAutodetectProcessTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutoDetectResultProcessorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushAcknowledgementTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushAcknowledgementTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushAcknowledgementTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushAcknowledgementTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListenerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListenerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListenerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/FlushListenerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/StateProcessorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParamsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParamsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParamsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/FlushJobParamsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParamsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParamsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParamsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParamsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRangeTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRangeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRangeTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/TimeRangeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/DataCountsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/DataCountsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/DataCountsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/DataCountsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/MemoryStatusTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/MemoryStatusTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/MemoryStatusTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/MemoryStatusTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSizeStatsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSnapshotTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSnapshotTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSnapshotTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/ModelSnapshotTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/QuantilesTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/QuantilesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/QuantilesTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/state/QuantilesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AbstractDataToProcessWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/AnalysisLimitsWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvDataToProcessWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvParserTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvParserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvParserTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvParserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/CsvRecordWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactoryTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactoryTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DataToProcessWriterFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DateFormatDateTransformerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/DoubleDateTransformerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/FieldConfigWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/JsonDataToProcessWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/LengthEncodedWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/MlFilterWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ModelPlotConfigWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventsWriterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/XContentRecordReaderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandlerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandlerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageHandlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/logging/CppLogMessageTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizableTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizableTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizableTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketInfluencerNormalizableTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizableTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizableTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizableTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/BucketNormalizableTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizableTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizableTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizableTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/InfluencerNormalizableTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResultTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResultTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResultTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerResultTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/NormalizerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdaterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdaterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdaterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ScoresUpdaterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/ShortCircuitingRenormalizerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandlerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandlerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/normalizer/output/NormalizerResultHandlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyCauseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AnomalyRecordTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/AutodetectResultTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketInfluencerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketInfluencerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketInfluencerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketInfluencerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/BucketTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/CategoryDefinitionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastRequestStatsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastRequestStatsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastRequestStatsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastRequestStatsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ForecastTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluenceTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluenceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluenceTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluenceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/InfluencerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ModelPlotTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/OverallBucketTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/OverallBucketTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/OverallBucketTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/OverallBucketTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/PartitionScoreTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemoverTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemoverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemoverTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredModelSnapshotsRemoverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemoverTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemoverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemoverTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/retention/ExpiredResultsRemoverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/GetModelSnapshotsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/GetModelSnapshotsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/GetModelSnapshotsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/GetModelSnapshotsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/UpdateModelSnapshotActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/UpdateModelSnapshotActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/UpdateModelSnapshotActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/modelsnapshots/UpdateModelSnapshotActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditMessageTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditMessageTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditMessageTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditMessageTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/AuditorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/LevelTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/LevelTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/notifications/LevelTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/notifications/LevelTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedActionTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedActionTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/rest/datafeeds/RestStartDatafeedActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index d1e7949d469..3aa78cbc65f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -26,8 +26,10 @@ import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.ml.LocalStateMachineLearning; import org.elasticsearch.xpack.ml.MLMetadataField; import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.action.CloseJobAction; import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction; @@ -44,6 +46,7 @@ import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.process.autodetect.state.DataCounts; +import org.elasticsearch.xpack.security.Security; import org.junit.After; import org.junit.Before; @@ -75,12 +78,12 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal)); - settings.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + settings.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), true); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); - settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); - settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); +// settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); +// settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); +// settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); return settings.build(); } @@ -89,15 +92,15 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { Settings.Builder settings = Settings.builder().put(super.transportClientSettings()); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), true); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); - settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); - settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); - settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); +// settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); +// settings.put(XPackSettings.MONITORING_ENABLED.getKey(), false); +// settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); return settings.build(); } @Override protected Collection> nodePlugins() { - return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, + return Arrays.asList(LocalStateMachineLearning.class, CommonAnalysisPlugin.class, ReindexPlugin.class); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/test/SearchHitBuilder.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/test/SearchHitBuilder.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/test/SearchHitBuilder.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/test/SearchHitBuilder.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/IntervalsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/IntervalsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/IntervalsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/IntervalsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/MlStringsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/MlStringsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/MlStringsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/MlStringsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/NameResolverTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NameResolverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/NameResolverTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NameResolverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/StatsAccumulatorTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/StatsAccumulatorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/StatsAccumulatorTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/StatsAccumulatorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/time/DateTimeFormatterTimestampConverterTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/time/DateTimeFormatterTimestampConverterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/time/DateTimeFormatterTimestampConverterTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/time/DateTimeFormatterTimestampConverterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/utils/time/TimeUtilsTests.java b/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/time/TimeUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ml/utils/time/TimeUtilsTests.java rename to plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/time/TimeUtilsTests.java diff --git a/plugin/monitoring/build.gradle b/plugin/monitoring/build.gradle index 1b311995178..1c1d9314408 100644 --- a/plugin/monitoring/build.gradle +++ b/plugin/monitoring/build.gradle @@ -1,22 +1,51 @@ -apply plugin: 'elasticsearch.build' - -dependencies { +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-monitoring' + description 'Elasticsearch Expanded Pack Plugin - Monitoring' + classname 'org.elasticsearch.xpack.monitoring.Monitoring' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') } - archivesBaseName = 'x-pack-monitoring' // TODO: enable this once we have tests -test.enabled=false licenseHeaders.enabled = false +integTest.enabled = false + dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') // monitoring deps compile "org.elasticsearch.client:elasticsearch-rest-client:${version}" compile "org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}" + + // baz - this goes away after we separate out the actions #27759 + testCompile "org.elasticsearch.plugin:x-pack-watcher:${version}" +} + +compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" +compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" + +// 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 } dependencyLicenses { @@ -29,6 +58,6 @@ dependencyLicenses { ignoreSha 'elasticsearch-rest-client-sniffer' } -parent.bundlePlugin { - from jar +run { + plugin ':x-pack-elasticsearch:plugin:core' } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java similarity index 81% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index 568ad2bef74..0289d62d3b6 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -19,14 +19,19 @@ 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.xcontent.NamedXContentRegistry; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.license.LicenseService; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; 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.XPackClientActionPlugin; -import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction; @@ -60,8 +65,6 @@ import java.util.function.Supplier; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.elasticsearch.common.settings.Setting.boolSetting; -import static org.elasticsearch.common.settings.Setting.timeSetting; -import static org.elasticsearch.xpack.XpackField.MONITORING; /** * This class activates/deactivates the monitoring modules depending if we're running a node client, transport client or tribe client: @@ -69,9 +72,7 @@ import static org.elasticsearch.xpack.XpackField.MONITORING; * - transport clients: only action/transport actions are binded * - tribe clients: everything is disables by default but can be enabled per tribe cluster */ -public class Monitoring implements ActionPlugin { - - public static final String NAME = "monitoring"; +public class Monitoring extends Plugin implements ActionPlugin { /** * The ability to automatically cleanup ".watcher_history*" indices while also cleaning up Monitoring indices. @@ -80,23 +81,22 @@ public class Monitoring implements ActionPlugin { false, Setting.Property.Dynamic, Setting.Property.NodeScope); - private final Settings settings; - private final XPackLicenseState licenseState; + protected final Settings settings; private final boolean enabled; private final boolean transportClientMode; private final boolean tribeNode; - public Monitoring(Settings settings, XPackLicenseState licenseState) { + public Monitoring(Settings settings) { this.settings = settings; - this.licenseState = licenseState; - this.enabled = XPackSettings.MONITORING_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); + this.enabled = XPackSettings.MONITORING_ENABLED.get(settings); this.tribeNode = XPackClientActionPlugin.isTribeNode(settings); } - public static Collection getNamedWriteables() { - return Arrays.asList(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, MONITORING, MonitoringFeatureSet.Usage::new)); - } + // overridable by tests + protected SSLService getSslService() { return XPackPlugin.getSharedSslService(); } + protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); } + protected LicenseService getLicenseService() { return XPackPlugin.getSharedLicenseService(); } boolean isEnabled() { return enabled; @@ -106,7 +106,8 @@ public class Monitoring implements ActionPlugin { return transportClientMode; } - public Collection nodeModules() { + @Override + public Collection createGuiceModules() { List modules = new ArrayList<>(); modules.add(b -> { XPackPlugin.bindFeatureSet(b, MonitoringFeatureSet.class); @@ -117,28 +118,32 @@ public class Monitoring implements ActionPlugin { return modules; } - public Collection createComponents(Client client, ThreadPool threadPool, ClusterService clusterService, - LicenseService licenseService, SSLService sslService) { + @Override + public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, + ResourceWatcherService resourceWatcherService, ScriptService scriptService, + NamedXContentRegistry xContentRegistry, Environment environment, + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { if (enabled == false || tribeNode) { return Collections.emptyList(); } final ClusterSettings clusterSettings = clusterService.getClusterSettings(); - final CleanerService cleanerService = new CleanerService(settings, clusterSettings, threadPool, licenseState); - final SSLService dynamicSSLService = sslService.createDynamicSSLService(); + final CleanerService cleanerService = new CleanerService(settings, clusterSettings, threadPool, getLicenseState()); + final SSLService dynamicSSLService = getSslService().createDynamicSSLService(); Map exporterFactories = new HashMap<>(); exporterFactories.put(HttpExporter.TYPE, config -> new HttpExporter(config, dynamicSSLService, threadPool.getThreadContext())); exporterFactories.put(LocalExporter.TYPE, config -> new LocalExporter(config, client, cleanerService)); - final Exporters exporters = new Exporters(settings, exporterFactories, clusterService, licenseState, threadPool.getThreadContext()); + final Exporters exporters = new Exporters(settings, exporterFactories, clusterService, getLicenseState(), + threadPool.getThreadContext()); Set collectors = new HashSet<>(); - collectors.add(new IndexStatsCollector(settings, clusterService, licenseState, client)); - collectors.add(new ClusterStatsCollector(settings, clusterService, licenseState, client, licenseService)); - collectors.add(new ShardsCollector(settings, clusterService, licenseState)); - collectors.add(new NodeStatsCollector(settings, clusterService, licenseState, client)); - collectors.add(new IndexRecoveryCollector(settings, clusterService, licenseState, client)); - collectors.add(new JobStatsCollector(settings, clusterService, licenseState, client)); + collectors.add(new IndexStatsCollector(settings, clusterService, getLicenseState(), client)); + collectors.add(new ClusterStatsCollector(settings, clusterService, getLicenseState(), client, getLicenseService())); + collectors.add(new ShardsCollector(settings, clusterService, getLicenseState())); + collectors.add(new NodeStatsCollector(settings, clusterService, getLicenseState(), client)); + collectors.add(new IndexRecoveryCollector(settings, clusterService, getLicenseState(), client)); + collectors.add(new JobStatsCollector(settings, clusterService, getLicenseState(), client)); final MonitoringService monitoringService = new MonitoringService(settings, clusterService, threadPool, collectors, exporters); @@ -163,6 +168,7 @@ public class Monitoring implements ActionPlugin { return singletonList(new RestMonitoringBulkAction(settings, restController)); } + @Override public List> getSettings() { return Collections.unmodifiableList( Arrays.asList(MonitoringField.HISTORY_DURATION, @@ -179,9 +185,9 @@ public class Monitoring implements ActionPlugin { ); } + @Override public List getSettingsFilter() { final String exportersKey = Exporters.EXPORTERS_SETTINGS.getKey(); return Collections.unmodifiableList(Arrays.asList(exportersKey + "*.auth.*", exportersKey + "*.ssl.*")); } - } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java similarity index 63% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java index 2b11ffc87ce..6f4fc5f93d7 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java +++ b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSet.java @@ -5,20 +5,17 @@ */ package org.elasticsearch.xpack.monitoring; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.monitoring.exporter.Exporter; import org.elasticsearch.xpack.monitoring.exporter.Exporters; @@ -37,7 +34,7 @@ public class MonitoringFeatureSet implements XPackFeatureSet { @Override public String name() { - return Monitoring.NAME; + return XPackField.MONITORING; } @Override @@ -62,7 +59,7 @@ public class MonitoringFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { - listener.onResponse(new Usage(available(), enabled(), exportersUsage(exporters))); + listener.onResponse(new MonitoringFeatureSetUsage(available(), enabled(), exportersUsage(exporters))); } static Map exportersUsage(Exporters exporters) { @@ -80,35 +77,4 @@ public class MonitoringFeatureSet implements XPackFeatureSet { return usage; } - public static class Usage extends XPackFeatureSet.Usage { - - private static final String ENABLED_EXPORTERS_XFIELD = "enabled_exporters"; - - @Nullable private Map exporters; - - public Usage(StreamInput in) throws IOException { - super(in); - exporters = in.readMap(); - } - - public Usage(boolean available, boolean enabled, Map exporters) { - super(Monitoring.NAME, available, enabled); - this.exporters = exporters; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeMap(exporters); - } - - @Override - protected void innerXContent(XContentBuilder builder, Params params) throws IOException { - super.innerXContent(builder, params); - if (exporters != null) { - builder.field(ENABLED_EXPORTERS_XFIELD, exporters); - } - } - } - } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkAction.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkAction.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java index 6b8d711c596..71a2c577925 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java +++ b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java @@ -18,8 +18,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc; import java.util.Collection; @@ -168,7 +167,7 @@ public abstract class Collector extends AbstractComponent { protected static String collectionSetting(final String settingName) { Objects.requireNonNull(settingName, "setting name must not be null"); - return XpackField.featureSettingPrefix(Monitoring.NAME) + ".collection." + settingName; + return XPackField.featureSettingPrefix(XPackField.MONITORING) + ".collection." + settingName; } protected static Setting collectionTimeoutSetting(final String settingName) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollector.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollector.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollector.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollector.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/BytesReferenceMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportException.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportException.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportException.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportException.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/FilteredMonitoringDoc.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListener.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListener.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListener.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulkResponseListener.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilder.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilder.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilder.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilder.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListener.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListener.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListener.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListener.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/Scheme.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/Scheme.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/Scheme.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/Scheme.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallback.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallback.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallback.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallback.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallback.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallback.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallback.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallback.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResource.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResource.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/MonitoringRestHandler.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java b/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java rename to plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkAction.java diff --git a/plugin/monitoring/src/main/plugin-metadata/plugin-security.policy b/plugin/monitoring/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/monitoring/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json b/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json rename to plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json diff --git a/plugin/src/main/resources/monitoring/watches/elasticsearch_nodes.json b/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/elasticsearch_nodes.json rename to plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json diff --git a/plugin/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json b/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json rename to plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json diff --git a/plugin/src/main/resources/monitoring/watches/kibana_version_mismatch.json b/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/kibana_version_mismatch.json rename to plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json diff --git a/plugin/src/main/resources/monitoring/watches/logstash_version_mismatch.json b/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/logstash_version_mismatch.json rename to plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json diff --git a/plugin/src/main/resources/monitoring/watches/xpack_license_expiration.json b/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json similarity index 100% rename from plugin/src/main/resources/monitoring/watches/xpack_license_expiration.json rename to plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/BaseCollectorTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/BaseCollectorTestCase.java similarity index 85% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/BaseCollectorTestCase.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/BaseCollectorTestCase.java index 8ae67bb8a3a..255184c46d7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/BaseCollectorTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/BaseCollectorTestCase.java @@ -3,7 +3,7 @@ * 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.monitoring.collector; +package org.elasticsearch.xpack.monitoring; import org.elasticsearch.Version; import org.elasticsearch.client.Client; @@ -20,10 +20,13 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.license.LicenseService; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.monitoring.collector.Collector; +import org.elasticsearch.xpack.ssl.SSLService; import java.util.function.Function; @@ -54,7 +57,9 @@ public abstract class BaseCollectorTestCase extends ESTestCase { ThreadPool threadPool = mock(ThreadPool.class); when(client.threadPool()).thenReturn(threadPool); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); - settings = Settings.EMPTY; + settings = Settings.builder() + .put("path.home", createTempDir()) + .build(); } protected void whenLocalNodeElectedMaster(final boolean electedMaster) { @@ -75,11 +80,11 @@ public abstract class BaseCollectorTestCase extends ESTestCase { when(metaData.clusterUUID()).thenReturn(clusterUUID); } - protected void withCollectionTimeout(final Setting collectionTimeout, final TimeValue timeout) { + protected void withCollectionTimeout(final Setting collectionTimeout, final TimeValue timeout) throws Exception { withCollectionSetting(builder -> builder.put(collectionTimeout.getKey(), timeout.getStringRep())); } - protected void withCollectionIndices(final String[] collectionIndices) { + protected void withCollectionIndices(final String[] collectionIndices) throws Exception { final String key = Collector.INDICES.getKey(); if (collectionIndices != null) { withCollectionSetting(builder -> builder.putList(key, collectionIndices)); @@ -88,13 +93,18 @@ public abstract class BaseCollectorTestCase extends ESTestCase { } } - protected void withCollectionSetting(final Function builder) { + protected void withCollectionSetting(final Function builder) throws Exception { settings = Settings.builder() .put(settings) .put(builder.apply(Settings.builder()).build()) .build(); when(clusterService.getClusterSettings()) - .thenReturn(new ClusterSettings(settings, Sets.newHashSet(new Monitoring(settings, licenseState).getSettings()))); + .thenReturn(new ClusterSettings(settings, Sets.newHashSet(new Monitoring(settings) { + @Override + protected XPackLicenseState getLicenseState() { + return licenseState; + } + }.getSettings()))); } protected static DiscoveryNode localNode(final String uuid) { diff --git a/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/LocalStateMonitoring.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/LocalStateMonitoring.java new file mode 100644 index 00000000000..bab05c4fb4c --- /dev/null +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/LocalStateMonitoring.java @@ -0,0 +1,51 @@ +/* + * 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.monitoring; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.LicenseService; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; + +import java.nio.file.Path; + +public class LocalStateMonitoring extends LocalStateCompositeXPackPlugin { + + public LocalStateMonitoring(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + LocalStateMonitoring thisVar = this; + + plugins.add(new Monitoring(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected LicenseService getLicenseService() { + return thisVar.getLicenseService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoredSystemTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java index 1a0191a65f1..5da23effd9b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringFeatureSetTests.java @@ -102,7 +102,7 @@ public class MonitoringFeatureSetTests extends ESTestCase { XPackFeatureSet.Usage monitoringUsage = future.get(); BytesStreamOutput out = new BytesStreamOutput(); monitoringUsage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new MonitoringFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new MonitoringFeatureSetUsage(out.bytes().streamInput()); for (XPackFeatureSet.Usage usage : Arrays.asList(monitoringUsage, serializedUsage)) { assertThat(usage.name(), is(featureSet.name())); assertThat(usage.enabled(), is(featureSet.enabled())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java similarity index 84% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java index 30c61b0f76b..6fb967c7978 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginClientTests.java @@ -14,24 +14,24 @@ import static org.hamcrest.Matchers.is; public class MonitoringPluginClientTests extends ESTestCase { - public void testModulesWithClientSettings() { + public void testModulesWithClientSettings() throws Exception { Settings settings = Settings.builder() .put("path.home", createTempDir()) .put(Client.CLIENT_TYPE_SETTING_S.getKey(), TransportClient.CLIENT_TYPE) .build(); - Monitoring plugin = new Monitoring(settings, null); + Monitoring plugin = new Monitoring(settings); assertThat(plugin.isEnabled(), is(true)); assertThat(plugin.isTransportClient(), is(true)); } - public void testModulesWithNodeSettings() { + public void testModulesWithNodeSettings() throws Exception { // these settings mimic what ES does when running as a node... Settings settings = Settings.builder() .put("path.home", createTempDir()) .put(Client.CLIENT_TYPE_SETTING_S.getKey(), "node") .build(); - Monitoring plugin = new Monitoring(settings, null); + Monitoring plugin = new Monitoring(settings); assertThat(plugin.isEnabled(), is(true)); assertThat(plugin.isTransportClient(), is(false)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java index 34d3591dc4c..adb81d9b798 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java @@ -45,8 +45,16 @@ public class MonitoringServiceTests extends ESTestCase { super.setUp(); threadPool = new TestThreadPool(getTestName()); clusterService = mock(ClusterService.class); + Settings settings = Settings.builder() + .put("path.home", createTempDir()) + .build(); - final Monitoring monitoring = new Monitoring(Settings.EMPTY, licenseState); + final Monitoring monitoring = new Monitoring(settings) { + @Override + protected XPackLicenseState getLicenseState() { + return licenseState; + } + }; clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(monitoring.getSettings())); when(clusterService.getClusterSettings()).thenReturn(clusterSettings); when(clusterService.state()).thenReturn(mock(ClusterState.class)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTestUtils.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTestUtils.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTestUtils.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTestUtils.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java index d5ced18fc0c..a8f55ddc132 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java @@ -14,6 +14,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; +import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.monitoring.collector.node.NodeStatsMonitoringDoc; import org.elasticsearch.xpack.monitoring.test.MonitoringIntegTestCase; import org.junit.After; @@ -27,6 +28,9 @@ import static org.hamcrest.Matchers.instanceOf; @ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0) public class MultiNodesStatsTests extends MonitoringIntegTestCase { + public MultiNodesStatsTests() throws Exception { + super(); + } @Override protected Settings nodeSettings(int nodeOrdinal) { @@ -47,6 +51,7 @@ public class MultiNodesStatsTests extends MonitoringIntegTestCase { int nodes = 0; int n = randomIntBetween(1, 2); + internalCluster().getPlugins(); internalCluster().startMasterOnlyNodes(n); nodes += n; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDocTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringIndexTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringIndexTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringIndexTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringIndexTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/TransportMonitoringBulkActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java index 21405c225f4..053355564b5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java @@ -26,6 +26,10 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; @ClusterScope(scope = TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0) public abstract class AbstractIndicesCleanerTestCase extends MonitoringIntegTestCase { + public AbstractIndicesCleanerTestCase() throws Exception { + super(); + } + static Integer INDEX_TEMPLATE_VERSION = null; @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java index 3ded05a2764..c749e318abf 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/local/LocalIndicesCleanerTests.java @@ -24,6 +24,10 @@ import static org.hamcrest.Matchers.equalTo; public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase { + public LocalIndicesCleanerTests() throws Exception { + super(); + } + private final boolean cleanUpWatcherHistory = randomBoolean(); @Override diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/CollectorTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/CollectorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/CollectorTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/CollectorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java similarity index 91% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java index 9bfe97b1249..261d5cf5f2a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java @@ -23,23 +23,23 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.license.License; import org.elasticsearch.license.LicenseService; +import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.action.XPackUsageAction; import org.elasticsearch.xpack.action.XPackUsageRequest; import org.elasticsearch.xpack.action.XPackUsageResponse; -import org.elasticsearch.xpack.logstash.Logstash; -import org.elasticsearch.xpack.logstash.LogstashFeatureSet; +import org.elasticsearch.xpack.monitoring.BaseCollectorTestCase; import org.elasticsearch.xpack.monitoring.MonitoredSystem; -import org.elasticsearch.xpack.monitoring.collector.BaseCollectorTestCase; +import org.elasticsearch.xpack.monitoring.MonitoringFeatureSetUsage; +import org.elasticsearch.xpack.monitoring.MonitoringTestUtils; import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc; +import org.junit.Assert; import java.util.Collection; import java.util.Locale; import java.util.UUID; import static java.util.Collections.singletonList; -import static org.elasticsearch.xpack.XPackSettings.SECURITY_ENABLED; -import static org.elasticsearch.xpack.XPackSettings.TRANSPORT_SSL_ENABLED; -import static org.elasticsearch.xpack.monitoring.MonitoringTestUtils.randomMonitoringNode; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; @@ -137,11 +137,11 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase { throw new AssertionError("Unknown mode [" + mode + "]"); } - settings.put(TRANSPORT_SSL_ENABLED.getKey(), transportTLSEnabled); + settings.put(XPackSettings.TRANSPORT_SSL_ENABLED.getKey(), transportTLSEnabled); } else { transportTLSEnabled = false; - settings.put(SECURITY_ENABLED.getKey(), false); + settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); } final TimeValue timeout = TimeValue.timeValueSeconds(randomIntBetween(1, 120)); @@ -155,7 +155,7 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase { final String clusterUUID = UUID.randomUUID().toString(); whenClusterStateWithUUID(clusterUUID); - final MonitoringDoc.Node node = randomMonitoringNode(random()); + final MonitoringDoc.Node node = MonitoringTestUtils.randomMonitoringNode(random()); final License license = License.builder() .uid(UUID.randomUUID().toString()) @@ -195,9 +195,12 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase { final IndexNameExpressionResolver indexNameExpressionResolver = mock(IndexNameExpressionResolver.class); final boolean apmIndicesExist = randomBoolean(); final Index[] indices = new Index[apmIndicesExist ? randomIntBetween(1, 5) : 0]; - when(indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.lenientExpandOpen(), "apm-*")).thenReturn(indices); + when(indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.lenientExpandOpen(), "apm-*")) + .thenReturn(indices); - final XPackUsageResponse xPackUsageResponse = new XPackUsageResponse(singletonList(new LogstashFeatureSet.Usage(true, true))); + // Baz - Changed from Logstash to Monitoring featureset + final XPackUsageResponse xPackUsageResponse = new XPackUsageResponse( + singletonList(new MonitoringFeatureSetUsage(true, true, null))); @SuppressWarnings("unchecked") final ActionFuture xPackUsageFuture = (ActionFuture) mock(ActionFuture.class); @@ -205,10 +208,10 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase { when(xPackUsageFuture.actionGet()).thenReturn(xPackUsageResponse); final ClusterStatsCollector collector = - new ClusterStatsCollector(settings.build(), clusterService, licenseState, client, licenseService, - indexNameExpressionResolver); + new ClusterStatsCollector(settings.build(), clusterService, licenseState, + client, licenseService, indexNameExpressionResolver); - assertEquals(timeout, collector.getCollectionTimeout()); + Assert.assertEquals(timeout, collector.getCollectionTimeout()); final long interval = randomNonNegativeLong(); @@ -241,7 +244,7 @@ public class ClusterStatsCollectorTests extends BaseCollectorTestCase { assertThat(document.getAPMIndicesExist(), is(apmIndicesExist)); assertThat(document.getUsages(), hasSize(1)); - assertThat(document.getUsages().iterator().next().name(), equalTo(Logstash.NAME)); + assertThat(document.getUsages().iterator().next().name(), equalTo(XPackField.MONITORING)); assertThat(document.getClusterState().getClusterName().value(), equalTo(clusterName)); assertThat(document.getClusterState().stateUUID(), equalTo(clusterState.stateUUID())); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java index 3440594c3bc..7be81846ae5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java @@ -44,8 +44,8 @@ import org.elasticsearch.plugins.PluginInfo; import org.elasticsearch.test.VersionUtils; import org.elasticsearch.transport.TransportInfo; import org.elasticsearch.xpack.XPackFeatureSet; -import org.elasticsearch.xpack.logstash.LogstashFeatureSet; import org.elasticsearch.xpack.monitoring.MonitoredSystem; +import org.elasticsearch.xpack.monitoring.MonitoringFeatureSetUsage; import org.elasticsearch.xpack.monitoring.exporter.BaseMonitoringDocTestCase; import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc; import org.junit.Before; @@ -254,7 +254,7 @@ public class ClusterStatsMonitoringDocTests extends BaseMonitoringDocTestCase usages = singletonList(new LogstashFeatureSet.Usage(false, true)); + final List usages = singletonList(new MonitoringFeatureSetUsage(false, true, null)); final NodeInfo mockNodeInfo = mock(NodeInfo.class); when(mockNodeInfo.getVersion()).thenReturn(Version.V_6_0_0_alpha2); @@ -553,7 +553,7 @@ public class ClusterStatsMonitoringDocTests extends BaseMonitoringDocTestCase clusterAlertBlacklist = rarely() ? randomSubsetOf(Arrays.asList(ClusterAlertsUtil.WATCH_IDS)) : Collections.emptyList(); private final boolean templatesExistsAlready = randomBoolean(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpHostBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MockHttpResource.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MockHttpResource.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MockHttpResource.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MockHttpResource.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/MultiHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListenerTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListenerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListenerTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/NodeFailureListenerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PipelineHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SchemeTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SchemeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SchemeTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SchemeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallbackTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallbackTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallbackTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/SecurityHttpClientConfigCallbackTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TemplateHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallbackTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallbackTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallbackTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/TimeoutRequestConfigCallbackTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResourceTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResourceTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/WatcherExistsHttpResourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java index b72cb46affc..ec9ad937794 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTestCase.java @@ -29,6 +29,10 @@ public abstract class LocalExporterIntegTestCase extends MonitoringIntegTestCase private static ThreadPool THREADPOOL; + public LocalExporterIntegTestCase() throws Exception { + super(); + } + @BeforeClass public static void setupThreadPool() { THREADPOOL = new TestThreadPool(LocalExporterIntegTestCase.class.getName()); @@ -47,7 +51,7 @@ public abstract class LocalExporterIntegTestCase extends MonitoringIntegTestCase .put("xpack.monitoring.exporters." + exporterName + ".type", LocalExporter.TYPE) .put("xpack.monitoring.exporters." + exporterName + ".enabled", false) .put("xpack.monitoring.exporters." + exporterName + "." + CLUSTER_ALERTS_MANAGEMENT_SETTING, false) - .put(XPackSettings.WATCHER_ENABLED.getKey(), false) +// .put(XPackSettings.WATCHER_ENABLED.getKey(), false) .put(NetworkModule.HTTP_ENABLED.getKey(), false) .build(); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java index 63fc4f2d87f..c43ce24c724 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java @@ -60,9 +60,12 @@ import static org.hamcrest.Matchers.is; @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1, numClientNodes = 0, transportClientRatio = 0.0, supportsDedicatedMasters = false) public class LocalExporterIntegTests extends LocalExporterIntegTestCase { - private final String indexTimeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM", null); + public LocalExporterIntegTests() throws Exception { + super(); + } + private void stopMonitoring() throws Exception { // Now disabling the monitoring service, so that no more collection are started assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings( diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java index 223dc96e604..e8eb0e9e959 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java @@ -31,6 +31,10 @@ import static org.hamcrest.Matchers.notNullValue; numDataNodes = 1, numClientNodes = 0, transportClientRatio = 0.0, supportsDedicatedMasters = false) public class LocalExporterResourceIntegTests extends LocalExporterIntegTestCase { + public LocalExporterResourceIntegTests() throws Exception { + super(); + } + private final MonitoredSystem system = randomFrom(MonitoredSystem.values()); public void testCreateWhenResourcesNeedToBeAddedOrUpdated() throws Exception { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index a3582eb1c6b..1931ff0e8c7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -49,7 +49,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.elasticsearch.common.xcontent.XContentHelper.toXContent; import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue; -import static org.elasticsearch.test.SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; +import static org.elasticsearch.test.SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; import static org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStatsMonitoringDoc.hash; import static org.elasticsearch.xpack.monitoring.exporter.MonitoringTemplateUtils.TEMPLATE_VERSION; import static org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockIngestPlugin.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/test/MockIngestPlugin.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockIngestPlugin.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/test/MockIngestPlugin.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java similarity index 86% rename from plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java rename to plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java index 2e9ead48b29..00932f5dea9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java +++ b/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/test/MonitoringIntegTestCase.java @@ -21,9 +21,9 @@ import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.store.MockFSIndexStore; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xpack.XPackClient; -import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.monitoring.LocalStateMonitoring; import org.elasticsearch.xpack.monitoring.MonitoringService; import org.elasticsearch.xpack.monitoring.client.MonitoringClient; import org.elasticsearch.xpack.monitoring.exporter.ClusterAlertsUtil; @@ -48,15 +48,27 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase { protected static final String MONITORING_INDICES_PREFIX = ".monitoring-"; protected static final String ALL_MONITORING_INDICES = MONITORING_INDICES_PREFIX + "*"; + public MonitoringIntegTestCase() throws Exception { +// super(); +// // The XPackPlugin is sometimes not loaded by the time the plugin components are loaded +// // so we do this to ensure that we wont get a NPE +// Settings settings = Settings.builder() +// .put("path.home", createTempDir()) +// .build(); +// +// // These tests do not load this plugin yet before spinning up some nodes +// new XPackPlugin(settings, null); + } + @Override protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(XPackSettings.SECURITY_ENABLED.getKey(), false) - .put(XPackSettings.WATCHER_ENABLED.getKey(), false) +// .put(XPackSettings.SECURITY_ENABLED.getKey(), false) +// .put(XPackSettings.WATCHER_ENABLED.getKey(), false) // Disable native ML autodetect_process as the c++ controller won't be available - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) - .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) +// .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) +// .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) // we do this by default in core, but for monitoring this isn't needed and only adds noise. .put("index.store.mock.check_index_on_close", false); @@ -66,7 +78,7 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase { @Override protected Settings transportClientSettings() { return Settings.builder().put(super.transportClientSettings()) - .put(XPackSettings.SECURITY_ENABLED.getKey(), false) +// .put(XPackSettings.SECURITY_ENABLED.getKey(), false) .put(XPackSettings.WATCHER_ENABLED.getKey(), false) .build(); } @@ -81,13 +93,14 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase { @Override protected Collection> nodePlugins() { - return Arrays.asList(XPackPlugin.class, MockPainlessScriptEngine.TestPlugin.class, MockIngestPlugin.class, - CommonAnalysisPlugin.class); + return Arrays.asList(LocalStateMonitoring.class, MockPainlessScriptEngine.TestPlugin.class, + MockIngestPlugin.class, CommonAnalysisPlugin.class); } @Override protected Collection> transportClientPlugins() { - return nodePlugins(); + return Arrays.asList(XPackClientPlugin.class, MockPainlessScriptEngine.TestPlugin.class, + MockIngestPlugin.class, CommonAnalysisPlugin.class); } protected MonitoringClient monitoringClient() { diff --git a/plugin/monitoring/src/test/resources/monitoring-test.json b/plugin/monitoring/src/test/resources/monitoring-test.json new file mode 100644 index 00000000000..e2abf9e699a --- /dev/null +++ b/plugin/monitoring/src/test/resources/monitoring-test.json @@ -0,0 +1,10 @@ +{ + "index_patterns": ".monitoring-data-${monitoring.template.version}", + "mappings": { + "doc": { + "_meta": { + "template.version": "${monitoring.template.version}" + } + } + } +} diff --git a/plugin/security/build.gradle b/plugin/security/build.gradle index 5c20ce921c2..b62aea6fb44 100644 --- a/plugin/security/build.gradle +++ b/plugin/security/build.gradle @@ -1,23 +1,69 @@ -apply plugin: 'elasticsearch.build' +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-security' + description 'Elasticsearch Expanded Pack Plugin - Security' + classname 'org.elasticsearch.xpack.security.Security' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} archivesBaseName = 'x-pack-security' // TODO: enable this once we have tests -test.enabled=false licenseHeaders.enabled = false +integTest.enabled = false + dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" - // security deps - compile project(path: ':modules:transport-netty4', configuration: 'runtime') + provided "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: ':modules:transport-netty4', configuration: 'runtime') + provided project(path: ':plugins:transport-nio', configuration: 'runtime') + + testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring') + testCompile project(path: ':x-pack-elasticsearch:plugin:watcher') + + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + + //compile project(path: ':modules:transport-netty4') 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' + 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 "org.yaml:snakeyaml:${versions.snakeyaml}" + } +compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" +compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" + +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 +} +//testClasses { +// dependsOn project(":x-pack-elasticsearch:plugin:core").testJar +//} +// TestUtils creates things in core, and the cli thinks that it needs to read from the core testArtifacts +// jar, so it fails with a zip file resource not found in getResource(Path) +sourceSets.test.resources { + srcDir '../core/src/test/resources' +} dependencyLicenses { mapping from: /netty-.*/, to: 'netty' mapping from: /bc.*/, to: 'bouncycastle' @@ -26,6 +72,33 @@ dependencyLicenses { ignoreSha 'transport-netty4' } -parent.bundlePlugin { - from jar +forbiddenPatterns { + exclude '**/*.key' + exclude '**/*.p12' + exclude '**/*.der' + exclude '**/*.zip' +} + +forbiddenApisMain { + signaturesURLs += file('forbidden/ldap-signatures.txt').toURI().toURL() +} + +run { + plugin ':x-pack-elasticsearch:plugin:core' +} + +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' } diff --git a/plugin/forbidden/ldap-signatures.txt b/plugin/security/forbidden/ldap-signatures.txt similarity index 100% rename from plugin/forbidden/ldap-signatures.txt rename to plugin/security/forbidden/ldap-signatures.txt diff --git a/plugin/bin/x-pack/certgen b/plugin/security/src/main/bin/certgen similarity index 100% rename from plugin/bin/x-pack/certgen rename to plugin/security/src/main/bin/certgen diff --git a/plugin/bin/x-pack/certgen.bat b/plugin/security/src/main/bin/certgen.bat similarity index 100% rename from plugin/bin/x-pack/certgen.bat rename to plugin/security/src/main/bin/certgen.bat diff --git a/plugin/bin/x-pack/certutil b/plugin/security/src/main/bin/certutil similarity index 100% rename from plugin/bin/x-pack/certutil rename to plugin/security/src/main/bin/certutil diff --git a/plugin/bin/x-pack/certutil.bat b/plugin/security/src/main/bin/certutil.bat similarity index 100% rename from plugin/bin/x-pack/certutil.bat rename to plugin/security/src/main/bin/certutil.bat diff --git a/plugin/bin/x-pack/migrate b/plugin/security/src/main/bin/migrate similarity index 100% rename from plugin/bin/x-pack/migrate rename to plugin/security/src/main/bin/migrate diff --git a/plugin/bin/x-pack/migrate.bat b/plugin/security/src/main/bin/migrate.bat similarity index 100% rename from plugin/bin/x-pack/migrate.bat rename to plugin/security/src/main/bin/migrate.bat diff --git a/plugin/bin/x-pack/setup-passwords b/plugin/security/src/main/bin/setup-passwords similarity index 100% rename from plugin/bin/x-pack/setup-passwords rename to plugin/security/src/main/bin/setup-passwords diff --git a/plugin/bin/x-pack/setup-passwords.bat b/plugin/security/src/main/bin/setup-passwords.bat similarity index 100% rename from plugin/bin/x-pack/setup-passwords.bat rename to plugin/security/src/main/bin/setup-passwords.bat diff --git a/plugin/bin/x-pack/syskeygen b/plugin/security/src/main/bin/syskeygen similarity index 100% rename from plugin/bin/x-pack/syskeygen rename to plugin/security/src/main/bin/syskeygen diff --git a/plugin/bin/x-pack/syskeygen.bat b/plugin/security/src/main/bin/syskeygen.bat similarity index 100% rename from plugin/bin/x-pack/syskeygen.bat rename to plugin/security/src/main/bin/syskeygen.bat diff --git a/plugin/bin/x-pack/users b/plugin/security/src/main/bin/users similarity index 100% rename from plugin/bin/x-pack/users rename to plugin/security/src/main/bin/users diff --git a/plugin/bin/x-pack/users.bat b/plugin/security/src/main/bin/users.bat similarity index 100% rename from plugin/bin/x-pack/users.bat rename to plugin/security/src/main/bin/users.bat diff --git a/plugin/config/x-pack/role_mapping.yml b/plugin/security/src/main/config/role_mapping.yml similarity index 100% rename from plugin/config/x-pack/role_mapping.yml rename to plugin/security/src/main/config/role_mapping.yml diff --git a/plugin/config/x-pack/roles.yml b/plugin/security/src/main/config/roles.yml similarity index 100% rename from plugin/config/x-pack/roles.yml rename to plugin/security/src/main/config/roles.yml diff --git a/plugin/config/x-pack/users b/plugin/security/src/main/config/users similarity index 100% rename from plugin/config/x-pack/users rename to plugin/security/src/main/config/users diff --git a/plugin/config/x-pack/users_roles b/plugin/security/src/main/config/users_roles similarity index 100% rename from plugin/config/x-pack/users_roles rename to plugin/security/src/main/config/users_roles diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java similarity index 95% rename from plugin/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java index 3faa517d904..01844cd56b3 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheck.java @@ -10,7 +10,7 @@ import org.elasticsearch.bootstrap.BootstrapContext; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.security.authc.RealmSettings; -import org.elasticsearch.xpack.security.authc.pki.PkiRealm; +import org.elasticsearch.xpack.security.authc.pki.PkiRealmSettings; import org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport; import org.elasticsearch.xpack.ssl.SSLService; @@ -35,7 +35,7 @@ class PkiRealmBootstrapCheck implements BootstrapCheck { public BootstrapCheckResult check(BootstrapContext context) { final Settings settings = context.settings; final boolean pkiRealmEnabled = settings.getGroups(RealmSettings.PREFIX).values().stream() - .filter(s -> PkiRealm.TYPE.equals(s.get("type"))) + .filter(s -> PkiRealmSettings.TYPE.equals(s.get("type"))) .anyMatch(s -> s.getAsBoolean("enabled", true)); if (pkiRealmEnabled) { // HTTP diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java similarity index 84% rename from plugin/src/main/java/org/elasticsearch/xpack/security/Security.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java index 8e5f1a80571..6008ad0dee9 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -16,7 +16,6 @@ import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; @@ -36,7 +35,6 @@ import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.IndexScopedSettings; -import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; @@ -52,6 +50,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.discovery.DiscoveryModule; import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.index.IndexModule; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -62,11 +61,14 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.ClusterPlugin; import org.elasticsearch.plugins.DiscoveryPlugin; +import org.elasticsearch.plugins.ExtensiblePlugin; import org.elasticsearch.plugins.IngestPlugin; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.NetworkPlugin; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; +import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; @@ -75,10 +77,8 @@ import org.elasticsearch.transport.TransportInterceptor; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.transport.TransportRequestHandler; import org.elasticsearch.watcher.ResourceWatcherService; -import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; import org.elasticsearch.xpack.extensions.XPackExtension; import org.elasticsearch.xpack.extensions.XPackExtensionsService; import org.elasticsearch.xpack.security.action.filter.SecurityActionFilter; @@ -127,10 +127,12 @@ import org.elasticsearch.xpack.security.action.user.TransportSetEnabledAction; import org.elasticsearch.xpack.security.audit.AuditTrail; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; +import org.elasticsearch.xpack.security.audit.index.IndexAuditTrailField; import org.elasticsearch.xpack.security.audit.index.IndexNameResolver; import org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail; import org.elasticsearch.xpack.security.authc.AuthenticationFailureHandler; import org.elasticsearch.xpack.security.authc.AuthenticationService; +import org.elasticsearch.xpack.security.authc.AuthenticationServiceField; import org.elasticsearch.xpack.security.authc.DefaultAuthenticationFailureHandler; import org.elasticsearch.xpack.security.authc.InternalRealms; import org.elasticsearch.xpack.security.authc.Realm; @@ -138,13 +140,13 @@ import org.elasticsearch.xpack.security.authc.RealmSettings; import org.elasticsearch.xpack.security.authc.Realms; import org.elasticsearch.xpack.security.authc.TokenMetaData; import org.elasticsearch.xpack.security.authc.TokenService; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore; -import org.elasticsearch.xpack.security.authc.support.mapper.expressiondsl.ExpressionParser; import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.RoleDescriptor; import org.elasticsearch.xpack.security.authz.SecuritySearchOperationListener; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; @@ -180,7 +182,6 @@ import org.elasticsearch.xpack.security.transport.SecurityServerTransportInterce import org.elasticsearch.xpack.security.transport.filter.IPFilter; import org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4HttpServerTransport; import org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4ServerTransport; -import org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport; import org.elasticsearch.xpack.security.user.AnonymousUser; import org.elasticsearch.xpack.ssl.SSLConfigurationSettings; import org.elasticsearch.xpack.ssl.SSLService; @@ -194,38 +195,39 @@ import org.joda.time.DateTimeZone; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.time.Clock; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; -import java.util.Optional; import java.util.Set; 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; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_FORMAT_SETTING; +import static org.elasticsearch.xpack.XPackPlugin.resolveXPackExtensionsFile; import static org.elasticsearch.xpack.XPackSettings.HTTP_SSL_ENABLED; import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_INDEX_NAME; -import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.security.SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME; import static org.elasticsearch.xpack.security.support.IndexLifecycleManager.INTERNAL_INDEX_FORMAT; -public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, ClusterPlugin, DiscoveryPlugin, MapperPlugin { +public class Security extends Plugin implements ActionPlugin, IngestPlugin, NetworkPlugin, ClusterPlugin, + DiscoveryPlugin, MapperPlugin, ExtensiblePlugin { - private static final Logger logger = Loggers.getLogger(XPackPlugin.class); - - public static final String NAME4 = XpackField.SECURITY + "4"; - public static final Setting> USER_SETTING = - new Setting<>(SecurityField.setting("user"), (String) null, Optional::ofNullable, Property.NodeScope); + private static final Logger logger = Loggers.getLogger(Security.class); static final Setting> AUDIT_OUTPUTS_SETTING = Setting.listSetting(SecurityField.setting("audit.outputs"), @@ -237,8 +239,6 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus private final Environment env; private final boolean enabled; private final boolean transportClientMode; - private final XPackLicenseState licenseState; - private final SSLService sslService; /* what a PITA that we need an extra indirection to initialize this. Yet, once we got rid of guice we can thing about how * to fix this or make it simpler. Today we need several service that are created in createComponents but we need to register * an instance of TransportInterceptor way earlier before createComponents is called. */ @@ -251,24 +251,27 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus private final SetOnce tokenService = new SetOnce<>(); private final SetOnce securityActionFilter = new SetOnce<>(); private final List bootstrapChecks; + private final XPackExtensionsService extensionsService; - public Security(Settings settings, Environment env, XPackLicenseState licenseState, SSLService sslService) { + public Security(Settings settings, final Path configPath) { this.settings = settings; - this.env = env; this.transportClientMode = XPackPlugin.transportClientMode(settings); + this.env = transportClientMode ? null : new Environment(settings, configPath); + this.extensionsService = transportClientMode ? null : new XPackExtensionsService(settings, resolveXPackExtensionsFile(env), + Collections.emptyList()); + this.enabled = XPackSettings.SECURITY_ENABLED.get(settings); if (enabled && transportClientMode == false) { validateAutoCreateIndex(settings); } - this.licenseState = licenseState; - this.sslService = sslService; + if (enabled) { // we load them all here otherwise we can't access secure settings since they are closed once the checks are // fetched final List checks = new ArrayList<>(); checks.addAll(Arrays.asList( new TokenSSLBootstrapCheck(), - new PkiRealmBootstrapCheck(sslService), + new PkiRealmBootstrapCheck(getSslService()), new TLSLicenseBootstrapCheck())); checks.addAll(InternalRealms.getBootstrapChecks(settings, env)); this.bootstrapChecks = Collections.unmodifiableList(checks); @@ -277,7 +280,8 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus } } - public Collection nodeModules() { + @Override + public Collection createGuiceModules() { List modules = new ArrayList<>(); if (enabled == false || transportClientMode) { modules.add(b -> b.bind(IPFilter.class).toProvider(Providers.of(null))); @@ -289,7 +293,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus } modules.add(b -> { // for transport client we still must inject these ssl classes with guice - b.bind(SSLService.class).toInstance(sslService); + b.bind(SSLService.class).toInstance(getSslService()); }); return modules; @@ -303,7 +307,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus b.bind(CompositeRolesStore.class).toProvider(Providers.of(null)); // for SecurityFeatureSet b.bind(NativeRoleMappingStore.class).toProvider(Providers.of(null)); // for SecurityFeatureSet b.bind(AuditTrailService.class) - .toInstance(new AuditTrailService(settings, Collections.emptyList(), licenseState)); + .toInstance(new AuditTrailService(settings, Collections.emptyList(), getLicenseState())); }); return modules; } @@ -319,12 +323,34 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus return modules; } + // overridable by tests + protected Clock getClock() { + return Clock.systemUTC(); + } + protected SSLService getSslService() { return XPackPlugin.getSharedSslService(); } + protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); } + + @Override + public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, + ResourceWatcherService resourceWatcherService, ScriptService scriptService, + NamedXContentRegistry xContentRegistry, Environment environment, + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { + try { + + return createComponents(client, threadPool, clusterService, resourceWatcherService, + extensionsService.getExtensions()); + } catch (final Exception e) { + throw new IllegalStateException("security initialization failed", e); + } + } + public Collection createComponents(Client client, ThreadPool threadPool, ClusterService clusterService, ResourceWatcherService resourceWatcherService, List extensions) throws Exception { if (enabled == false) { return Collections.emptyList(); } + threadContext.set(threadPool.getThreadContext()); List components = new ArrayList<>(); securityContext.set(new SecurityContext(settings, threadPool.getThreadContext())); @@ -355,7 +381,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus } } final AuditTrailService auditTrailService = - new AuditTrailService(settings, new ArrayList<>(auditTrails), licenseState); + new AuditTrailService(settings, new ArrayList<>(auditTrails), getLicenseState()); components.add(auditTrailService); this.auditTrailService.set(auditTrailService); @@ -372,7 +398,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus final ReservedRealm reservedRealm = new ReservedRealm(env, settings, nativeUsersStore, anonymousUser, securityLifecycleService, threadPool.getThreadContext()); Map realmFactories = new HashMap<>(InternalRealms.getFactories(threadPool, resourceWatcherService, - sslService, nativeUsersStore, nativeRoleMappingStore, securityLifecycleService)); + getSslService(), nativeUsersStore, nativeRoleMappingStore, securityLifecycleService)); for (XPackExtension extension : extensions) { Map newRealms = extension.getRealms(resourceWatcherService); for (Map.Entry entry : newRealms.entrySet()) { @@ -381,7 +407,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus } } } - final Realms realms = new Realms(settings, env, realmFactories, licenseState, threadPool.getThreadContext(), reservedRealm); + final Realms realms = new Realms(settings, env, realmFactories, getLicenseState(), threadPool.getThreadContext(), reservedRealm); components.add(nativeUsersStore); components.add(nativeRoleMappingStore); components.add(realms); @@ -405,23 +431,24 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus logger.debug("Using authentication failure handler from extension [" + extensionName + "]"); } - authcService.set(new AuthenticationService(settings, realms, auditTrailService, failureHandler, threadPool, anonymousUser, tokenService)); + authcService.set(new AuthenticationService(settings, realms, auditTrailService, failureHandler, threadPool, + anonymousUser, tokenService)); components.add(authcService.get()); - final FileRolesStore fileRolesStore = new FileRolesStore(settings, env, resourceWatcherService, licenseState); - final NativeRolesStore nativeRolesStore = new NativeRolesStore(settings, client, licenseState, securityLifecycleService); + final FileRolesStore fileRolesStore = new FileRolesStore(settings, env, resourceWatcherService, getLicenseState()); + final NativeRolesStore nativeRolesStore = new NativeRolesStore(settings, client, getLicenseState(), securityLifecycleService); final ReservedRolesStore reservedRolesStore = new ReservedRolesStore(); List, ActionListener>>> rolesProviders = new ArrayList<>(); for (XPackExtension extension : extensions) { rolesProviders.addAll(extension.getRolesProviders(settings, resourceWatcherService)); } final CompositeRolesStore allRolesStore = new CompositeRolesStore(settings, fileRolesStore, nativeRolesStore, - reservedRolesStore, rolesProviders, threadPool.getThreadContext(), licenseState); + reservedRolesStore, rolesProviders, threadPool.getThreadContext(), getLicenseState()); securityLifecycleService.addSecurityIndexHealthChangeListener(allRolesStore::onSecurityIndexHealthChange); securityLifecycleService.addSecurityIndexOutOfDateListener(allRolesStore::onSecurityIndexOutOfDateChange); // to keep things simple, just invalidate all cached entries on license change. this happens so rarely that the impact should be // minimal - licenseState.addListener(allRolesStore::invalidateAll); + getLicenseState().addListener(allRolesStore::invalidateAll); final AuthorizationService authzService = new AuthorizationService(settings, allRolesStore, clusterService, auditTrailService, failureHandler, threadPool, anonymousUser); components.add(nativeRolesStore); // used by roles actions @@ -431,79 +458,78 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus components.add(securityLifecycleService); - ipFilter.set(new IPFilter(settings, auditTrailService, clusterService.getClusterSettings(), licenseState)); + ipFilter.set(new IPFilter(settings, auditTrailService, clusterService.getClusterSettings(), getLicenseState())); components.add(ipFilter.get()); DestructiveOperations destructiveOperations = new DestructiveOperations(settings, clusterService.getClusterSettings()); - securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState, - sslService, securityContext.get(), destructiveOperations)); + securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), + authzService, getLicenseState(), getSslService(), securityContext.get(), destructiveOperations)); final Set requestInterceptors; if (XPackSettings.DLS_FLS_ENABLED.get(settings)) { requestInterceptors = Collections.unmodifiableSet(Sets.newHashSet( - new SearchRequestInterceptor(settings, threadPool, licenseState), - new UpdateRequestInterceptor(settings, threadPool, licenseState), - new BulkShardRequestInterceptor(settings, threadPool, licenseState), - new ResizeRequestInterceptor(settings, threadPool, licenseState, auditTrailService), - new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), licenseState, auditTrailService))); + new SearchRequestInterceptor(settings, threadPool, getLicenseState()), + new UpdateRequestInterceptor(settings, threadPool, getLicenseState()), + new BulkShardRequestInterceptor(settings, threadPool, getLicenseState()), + new ResizeRequestInterceptor(settings, threadPool, getLicenseState(), auditTrailService), + new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService))); } else { requestInterceptors = Collections.emptySet(); } - securityActionFilter.set(new SecurityActionFilter(settings, authcService.get(), authzService, licenseState, + securityActionFilter.set(new SecurityActionFilter(settings, authcService.get(), authzService, getLicenseState(), requestInterceptors, threadPool, securityContext.get(), destructiveOperations)); return components; } + @Override public Settings additionalSettings() { - if (enabled == false) { - return Settings.EMPTY; - } - - return additionalSettings(settings, transportClientMode); + return additionalSettings(settings, enabled, transportClientMode); } // visible for tests - static Settings additionalSettings(Settings settings, boolean transportClientMode) { - final Settings.Builder settingsBuilder = Settings.builder(); + static Settings additionalSettings(final Settings settings, final boolean enabled, final boolean transportClientMode) { + if (enabled && transportClientMode == false) { + final Settings.Builder builder = Settings.builder(); - if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings)) { - final String transportType = NetworkModule.TRANSPORT_TYPE_SETTING.get(settings); - if (NAME4.equals(transportType) == false) { - throw new IllegalArgumentException("transport type setting [" + NetworkModule.TRANSPORT_TYPE_KEY + "] must be [" + NAME4 - + "] but is [" + transportType + "]"); - } - } else { - // default to security4 - settingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, NAME4); - } + builder.put(SecuritySettings.addTransportSettings(settings)); - if (NetworkModule.HTTP_TYPE_SETTING.exists(settings)) { - final String httpType = NetworkModule.HTTP_TYPE_SETTING.get(settings); - if (httpType.equals(NAME4)) { - SecurityNetty4HttpServerTransport.overrideSettings(settingsBuilder, settings); + if (NetworkModule.HTTP_TYPE_SETTING.exists(settings)) { + final String httpType = NetworkModule.HTTP_TYPE_SETTING.get(settings); + if (httpType.equals(SecurityField.NAME4)) { + SecurityNetty4HttpServerTransport.overrideSettings(builder, settings); + } else { + final String message = String.format( + Locale.ROOT, + "http type setting [%s] must be [%s] but is [%s]", + NetworkModule.HTTP_TYPE_KEY, + SecurityField.NAME4, + httpType); + throw new IllegalArgumentException(message); + } } else { - throw new IllegalArgumentException("http type setting [" + NetworkModule.HTTP_TYPE_KEY + "] must be [" + NAME4 - + "] but is [" + httpType + "]"); + // default to security4 + builder.put(NetworkModule.HTTP_TYPE_KEY, SecurityField.NAME4); + SecurityNetty4HttpServerTransport.overrideSettings(builder, settings); } + builder.put(SecuritySettings.addUserSettings(settings)); + addTribeSettings(settings, builder); + return builder.build(); } else { - // default to security4 - settingsBuilder.put(NetworkModule.HTTP_TYPE_KEY, NAME4); - SecurityNetty4HttpServerTransport.overrideSettings(settingsBuilder, settings); + return Settings.EMPTY; } - - addUserSettings(settings, settingsBuilder); - addTribeSettings(settings, settingsBuilder); - return settingsBuilder.build(); } - /** - * Get the {@link Setting setting configuration} for all security components, including those defined in extensions. - */ + @Override + public List> getSettings() { + return getSettings(transportClientMode, extensionsService); + } + + /** + * Get the {@link Setting setting configuration} for all security components, including those defined in extensions. + */ public static List> getSettings(boolean transportClientMode, @Nullable XPackExtensionsService extensionsService) { List> settingsList = new ArrayList<>(); - // always register for both client and node modes - settingsList.add(USER_SETTING); if (transportClientMode) { return settingsList; @@ -540,26 +566,45 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus return settingsList; } - - public List getSettingsFilter(@Nullable XPackExtensionsService extensionsService) { + @Override + public Collection getRestHeaders() { + if (transportClientMode) { + return Collections.emptyList(); + } + Set headers = new HashSet<>(); + headers.add(UsernamePasswordToken.BASIC_AUTH_HEADER); + if (AuthenticationServiceField.RUN_AS_ENABLED.get(settings)) { + headers.add(AuthenticationServiceField.RUN_AS_USER_HEADER); + } + headers.addAll(extensionsService.getExtensions().stream() + .flatMap(e -> e.getRestHeaders().stream()).collect(Collectors.toList())); + return headers; + } + + @Override + public List getSettingsFilter() { List asArray = settings.getAsList(SecurityField.setting("hide_settings")); ArrayList settingsFilter = new ArrayList<>(asArray); - - final List extensions = extensionsService == null ? Collections.emptyList() : extensionsService.getExtensions(); - settingsFilter.addAll(RealmSettings.getSettingsFilter(extensions)); - + if (transportClientMode == false) { + settingsFilter.addAll(RealmSettings.getSettingsFilter(extensionsService.getExtensions())); + for (XPackExtension extension : extensionsService.getExtensions()) { + settingsFilter.addAll(extension.getSettingsFilter()); + } + } // hide settings where we don't define them - they are part of a group... settingsFilter.add("transport.profiles.*." + SecurityField.setting("*")); return settingsFilter; } + @Override public List getBootstrapChecks() { return bootstrapChecks; } + @Override public void onIndexModule(IndexModule module) { if (enabled) { - assert licenseState != null; + assert getLicenseState() != null; if (XPackSettings.DLS_FLS_ENABLED.get(settings)) { module.setSearcherWrapper(indexService -> new SecurityIndexSearcherWrapper(indexService.getIndexSettings(), @@ -572,7 +617,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus }, null), indexService.cache().bitsetFilterCache(), - indexService.getThreadPool().getThreadContext(), licenseState, + indexService.getThreadPool().getThreadContext(), getLicenseState(), indexService.getScriptService())); /* We need to forcefully overwrite the query cache implementation to use security's opt out query cache implementation. * This impl. disabled the query cache if field level security is used for a particular request. If we wouldn't do @@ -585,7 +630,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus // attaches information to the scroll context so that we can validate the user that created the scroll against // the user that is executing a scroll operation module.addSearchOperationListener( - new SecuritySearchOperationListener(threadContext.get(), licenseState, auditTrailService.get())); + new SecuritySearchOperationListener(threadContext.get(), getLicenseState(), auditTrailService.get())); } } @@ -637,23 +682,23 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus return emptyList(); } return Arrays.asList( - new RestAuthenticateAction(settings, restController, securityContext.get(), licenseState), - new RestClearRealmCacheAction(settings, restController, licenseState), - new RestClearRolesCacheAction(settings, restController, licenseState), - new RestGetUsersAction(settings, restController, licenseState), - new RestPutUserAction(settings, restController, licenseState), - new RestDeleteUserAction(settings, restController, licenseState), - new RestGetRolesAction(settings, restController, licenseState), - new RestPutRoleAction(settings, restController, licenseState), - new RestDeleteRoleAction(settings, restController, licenseState), - new RestChangePasswordAction(settings, restController, securityContext.get(), licenseState), - new RestSetEnabledAction(settings, restController, licenseState), - new RestHasPrivilegesAction(settings, restController, securityContext.get(), licenseState), - new RestGetRoleMappingsAction(settings, restController, licenseState), - new RestPutRoleMappingAction(settings, restController, licenseState), - new RestDeleteRoleMappingAction(settings, restController, licenseState), - new RestGetTokenAction(settings, restController, licenseState), - new RestInvalidateTokenAction(settings, restController, licenseState), + new RestAuthenticateAction(settings, restController, securityContext.get(), getLicenseState()), + new RestClearRealmCacheAction(settings, restController, getLicenseState()), + new RestClearRolesCacheAction(settings, restController, getLicenseState()), + new RestGetUsersAction(settings, restController, getLicenseState()), + new RestPutUserAction(settings, restController, getLicenseState()), + new RestDeleteUserAction(settings, restController, getLicenseState()), + new RestGetRolesAction(settings, restController, getLicenseState()), + new RestPutRoleAction(settings, restController, getLicenseState()), + new RestDeleteRoleAction(settings, restController, getLicenseState()), + new RestChangePasswordAction(settings, restController, securityContext.get(), getLicenseState()), + new RestSetEnabledAction(settings, restController, getLicenseState()), + new RestHasPrivilegesAction(settings, restController, securityContext.get(), getLicenseState()), + new RestGetRoleMappingsAction(settings, restController, getLicenseState()), + new RestPutRoleMappingAction(settings, restController, getLicenseState()), + new RestDeleteRoleMappingAction(settings, restController, getLicenseState()), + new RestGetTokenAction(settings, restController, getLicenseState()), + new RestInvalidateTokenAction(settings, restController, getLicenseState()), new RestGetCertificateInfoAction(settings, restController) ); } @@ -663,24 +708,6 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus return Collections.singletonMap(SetSecurityUserProcessor.TYPE, new SetSecurityUserProcessor.Factory(parameters.threadContext)); } - private static void addUserSettings(Settings settings, Settings.Builder settingsBuilder) { - String authHeaderSettingName = ThreadContext.PREFIX + "." + UsernamePasswordToken.BASIC_AUTH_HEADER; - if (settings.get(authHeaderSettingName) != null) { - return; - } - Optional userOptional = USER_SETTING.get(settings); // TODO migrate to securesetting! - userOptional.ifPresent(userSetting -> { - final int i = userSetting.indexOf(":"); - if (i < 0 || i == userSetting.length() - 1) { - throw new IllegalArgumentException("invalid [" + USER_SETTING.getKey() + "] setting. must be in the form of " + - "\":\""); - } - String username = userSetting.substring(0, i); - String password = userSetting.substring(i + 1); - settingsBuilder.put(authHeaderSettingName, UsernamePasswordToken.basicAuthHeaderValue(username, new SecureString(password))); - }); - } - /** * If the current node is a tribe node, we inject additional settings on each tribe client. We do this to make sure * that every tribe cluster has x-pack installed and security is enabled. We do that by: @@ -729,7 +756,8 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus final boolean hasNativeRealm = XPackSettings.RESERVED_REALM_ENABLED_SETTING.get(settings) || realmsSettings.isEmpty() || realmsSettings.entrySet().stream() - .anyMatch((e) -> NativeRealm.TYPE.equals(e.getValue().get("type")) && e.getValue().getAsBoolean("enabled", true)); + .anyMatch((e) -> NativeRealmSettings.TYPE.equals(e.getValue().get("type")) && e.getValue() + .getAsBoolean("enabled", true)); if (hasNativeRealm) { if (settings.get("tribe.on_conflict", "").startsWith("prefer_") == false) { throw new IllegalArgumentException("use of security on tribe nodes requires setting [tribe.on_conflict] to specify the " + @@ -759,7 +787,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus final boolean indexAuditingEnabled = Security.indexAuditLoggingEnabled(settings); if (indexAuditingEnabled) { - String auditIndex = IndexAuditTrail.INDEX_NAME_PREFIX + "*"; + String auditIndex = IndexAuditTrailField.INDEX_NAME_PREFIX + "*"; String errorMessage = LoggerMessageFormat.format( "the [action.auto_create_index] setting value [{}] is too" + " restrictive. disable [action.auto_create_index] or set it to include " + @@ -776,14 +804,22 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus List indices = new ArrayList<>(); DateTime now = new DateTime(DateTimeZone.UTC); // just use daily rollover - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now, IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusDays(1), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(1), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(2), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(3), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(4), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(5), IndexNameResolver.Rollover.DAILY)); - indices.add(IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now.plusMonths(6), IndexNameResolver.Rollover.DAILY)); + + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now, IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusDays(1), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(1), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(2), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(3), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(4), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(5), + IndexNameResolver.Rollover.DAILY)); + indices.add(IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now.plusMonths(6), + IndexNameResolver.Rollover.DAILY)); for (String index : indices) { boolean matched = false; @@ -846,11 +882,11 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) { - if (enabled == false) { // don't register anything if we are not enabled + if (transportClientMode || enabled == false) { // don't register anything if we are not enabled, or in transport client mode return Collections.emptyMap(); } - return Collections.singletonMap(Security.NAME4, () -> new SecurityNetty4ServerTransport(settings, threadPool, networkService, bigArrays, - namedWriteableRegistry, circuitBreakerService, ipFilter.get(), sslService)); + return Collections.singletonMap(SecurityField.NAME4, () -> new SecurityNetty4ServerTransport(settings, threadPool, + networkService, bigArrays, namedWriteableRegistry, circuitBreakerService, ipFilter.get(), getSslService())); } @Override @@ -863,8 +899,8 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus if (enabled == false) { // don't register anything if we are not enabled return Collections.emptyMap(); } - return Collections.singletonMap(Security.NAME4, () -> new SecurityNetty4HttpServerTransport(settings, networkService, bigArrays, - ipFilter.get(), sslService, threadPool, xContentRegistry, dispatcher)); + return Collections.singletonMap(SecurityField.NAME4, () -> new SecurityNetty4HttpServerTransport(settings, + networkService, bigArrays, ipFilter.get(), getSslService(), threadPool, xContentRegistry, dispatcher)); } @Override @@ -874,20 +910,12 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus } final boolean ssl = HTTP_SSL_ENABLED.get(settings); Settings httpSSLSettings = SSLService.getHttpTransportSSLSettings(settings); - boolean extractClientCertificate = ssl && sslService.isSSLClientAuthEnabled(httpSSLSettings); - return handler -> new SecurityRestFilter(licenseState, threadContext, authcService.get(), handler, + boolean extractClientCertificate = ssl && getSslService().isSSLClientAuthEnabled(httpSSLSettings); + return handler -> new SecurityRestFilter(getLicenseState(), threadContext, authcService.get(), handler, extractClientCertificate); } - public static List getNamedWriteables() { - List entries = new ArrayList<>(); - entries.add(new NamedWriteableRegistry.Entry(ClusterState.Custom.class, TokenMetaData.TYPE, TokenMetaData::new)); - entries.add(new NamedWriteableRegistry.Entry(NamedDiff.class, TokenMetaData.TYPE, TokenMetaData::readDiffFrom)); - entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XpackField.SECURITY, SecurityFeatureSet.Usage::new)); - entries.addAll(Arrays.asList(ExpressionParser.NAMED_WRITEABLES)); - return entries; - } - + @Override public List> getExecutorBuilders(final Settings settings) { if (enabled && transportClientMode == false) { return Collections.singletonList( @@ -896,6 +924,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus return Collections.emptyList(); } + @Override public UnaryOperator> getIndexTemplateMetaDataUpgrader() { return templates -> { templates.remove(SECURITY_TEMPLATE_NAME); @@ -931,10 +960,11 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus public Function> getFieldFilter() { if (enabled) { return index -> { - if (licenseState.isDocumentAndFieldLevelSecurityAllowed() == false) { + if (getLicenseState().isDocumentAndFieldLevelSecurityAllowed() == false) { return MapperPlugin.NOOP_FIELD_PREDICATE; } - IndicesAccessControl indicesAccessControl = threadContext.get().getTransient(AuthorizationService.INDICES_PERMISSIONS_KEY); + IndicesAccessControl indicesAccessControl = threadContext.get().getTransient( + AuthorizationServiceField.INDICES_PERMISSIONS_KEY); IndicesAccessControl.IndexAccessControl indexPermissions = indicesAccessControl.getIndexPermissions(index); if (indexPermissions == null) { return MapperPlugin.NOOP_FIELD_PREDICATE; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java similarity index 60% rename from plugin/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java index b685f2dedab..b3eac1578da 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityFeatureSet.java @@ -5,25 +5,20 @@ */ package org.elasticsearch.xpack.security; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.CountDown; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.authc.Realms; import org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; @@ -67,7 +62,7 @@ public class SecurityFeatureSet implements XPackFeatureSet { @Override public String name() { - return XpackField.SECURITY; + return XPackField.SECURITY; } @Override @@ -103,7 +98,7 @@ public class SecurityFeatureSet implements XPackFeatureSet { final CountDown countDown = new CountDown(2); final Runnable doCountDown = () -> { if (countDown.countDown()) { - listener.onResponse(new Usage(available(), enabled(), realmsUsage, + listener.onResponse(new SecurityFeatureSetUsage(available(), enabled(), realmsUsage, rolesUsageRef.get(), roleMappingUsageRef.get(), sslUsage, auditUsage, ipFilterUsage, anonymousUsage)); } @@ -162,81 +157,4 @@ public class SecurityFeatureSet implements XPackFeatureSet { return ipFilter.usageStats(); } - public static class Usage extends XPackFeatureSet.Usage { - - private static final String REALMS_XFIELD = "realms"; - private static final String ROLES_XFIELD = "roles"; - private static final String ROLE_MAPPING_XFIELD = "role_mapping"; - private static final String SSL_XFIELD = "ssl"; - private static final String AUDIT_XFIELD = "audit"; - private static final String IP_FILTER_XFIELD = "ipfilter"; - private static final String ANONYMOUS_XFIELD = "anonymous"; - - private Map realmsUsage; - private Map rolesStoreUsage; - private Map sslUsage; - private Map auditUsage; - private Map ipFilterUsage; - private Map anonymousUsage; - private Map roleMappingStoreUsage; - - public Usage(StreamInput in) throws IOException { - super(in); - realmsUsage = in.readMap(); - rolesStoreUsage = in.readMap(); - sslUsage = in.readMap(); - auditUsage = in.readMap(); - ipFilterUsage = in.readMap(); - if (in.getVersion().before(Version.V_6_0_0_beta1)) { - // system key has been removed but older send its usage, so read the map and ignore - in.readMap(); - } - anonymousUsage = in.readMap(); - roleMappingStoreUsage = in.readMap(); - } - - public Usage(boolean available, boolean enabled, Map realmsUsage, - Map rolesStoreUsage, Map roleMappingStoreUsage, - Map sslUsage, Map auditUsage, - Map ipFilterUsage, Map anonymousUsage) { - super(XpackField.SECURITY, available, enabled); - this.realmsUsage = realmsUsage; - this.rolesStoreUsage = rolesStoreUsage; - this.roleMappingStoreUsage = roleMappingStoreUsage; - this.sslUsage = sslUsage; - this.auditUsage = auditUsage; - this.ipFilterUsage = ipFilterUsage; - this.anonymousUsage = anonymousUsage; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeMap(realmsUsage); - out.writeMap(rolesStoreUsage); - out.writeMap(sslUsage); - out.writeMap(auditUsage); - out.writeMap(ipFilterUsage); - if (out.getVersion().before(Version.V_6_0_0_beta1)) { - // system key has been removed but older versions still expected it so send a empty map - out.writeMap(Collections.emptyMap()); - } - out.writeMap(anonymousUsage); - out.writeMap(roleMappingStoreUsage); - } - - @Override - protected void innerXContent(XContentBuilder builder, Params params) throws IOException { - super.innerXContent(builder, params); - if (enabled) { - builder.field(REALMS_XFIELD, realmsUsage); - builder.field(ROLES_XFIELD, rolesStoreUsage); - builder.field(ROLE_MAPPING_XFIELD, roleMappingStoreUsage); - builder.field(SSL_XFIELD, sslUsage); - builder.field(AUDIT_XFIELD, auditUsage); - builder.field(IP_FILTER_XFIELD, ipFilterUsage); - builder.field(ANONYMOUS_XFIELD, anonymousUsage); - } - } - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java index 8dd7a3b0c9c..a9c12b2c7e5 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/SecurityLifecycleService.java @@ -45,9 +45,8 @@ import java.util.function.Predicate; */ public class SecurityLifecycleService extends AbstractComponent implements ClusterStateListener { - public static final String SECURITY_INDEX_NAME = ".security"; - public static final String SECURITY_TEMPLATE_NAME = "security-index-template"; public static final String INTERNAL_SECURITY_INDEX = IndexLifecycleManager.INTERNAL_SECURITY_INDEX; + public static final String SECURITY_INDEX_NAME = ".security"; private static final Version MIN_READ_VERSION = Version.V_5_0_0; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/TokenSSLBootstrapCheck.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/TokenSSLBootstrapCheck.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/TokenSSLBootstrapCheck.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/TokenSSLBootstrapCheck.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/SecurityActionMapper.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/SecurityActionMapper.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/SecurityActionMapper.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/SecurityActionMapper.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java index a8738c054d2..81ccb354dc1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java @@ -24,7 +24,7 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.SecurityContext; import org.elasticsearch.xpack.security.action.SecurityActionMapper; import org.elasticsearch.xpack.security.action.interceptor.RequestInterceptor; @@ -81,7 +81,7 @@ public class SecurityActionFilter extends AbstractComponent implements ActionFil logger.error("blocking [{}] operation due to expired license. Cluster health, cluster stats and indices stats \n" + "operations are blocked on license expiration. All data operations (read and write) continue to work. \n" + "If you have a new license, please update it. Otherwise, please reach out to your support contact.", action); - throw LicenseUtils.newComplianceException(XpackField.SECURITY); + throw LicenseUtils.newComplianceException(XPackField.SECURITY); } if (licenseState.isAuthAllowed()) { @@ -116,7 +116,7 @@ public class SecurityActionFilter extends AbstractComponent implements ActionFil listener.onFailure(e); } } else if (SECURITY_ACTION_MATCHER.test(action)) { - listener.onFailure(LicenseUtils.newComplianceException(XpackField.SECURITY)); + listener.onFailure(LicenseUtils.newComplianceException(XPackField.SECURITY)); } else { chain.proceed(task, action, request, listener); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java index 5c205f388f9..0fa26d3bb0c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/BulkShardRequestInterceptor.java @@ -16,7 +16,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportRequest; -import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.Role; import org.elasticsearch.xpack.security.user.User; @@ -39,7 +39,7 @@ public class BulkShardRequestInterceptor extends AbstractComponent implements Re if (licenseState.isDocumentAndFieldLevelSecurityAllowed() == false) { return; } - IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationService.INDICES_PERMISSIONS_KEY); + IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY); for (BulkItemRequest bulkItemRequest : request.items()) { IndicesAccessControl.IndexAccessControl indexAccessControl = indicesAccessControl.getIndexPermissions(bulkItemRequest.index()); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java index 6cae676eeff..b835de8a732 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/interceptor/FieldAndDocumentLevelSecurityRequestInterceptor.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.Role; import org.elasticsearch.xpack.security.user.User; @@ -36,7 +36,7 @@ abstract class FieldAndDocumentLevelSecurityRequestInterceptor { @@ -33,7 +33,7 @@ public class TransportDeleteRoleAction extends HandledTransportAction listener) { - if (ClientReservedRoles.isReserved(request.name())) { + if (ReservedRolesStore.isReserved(request.name())) { listener.onFailure(new IllegalArgumentException("role [" + request.name() + "] is reserved and cannot be deleted")); return; } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java similarity index 96% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java index b8734c41654..29097391896 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesAction.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.authz.store.ClientReservedRoles; import org.elasticsearch.xpack.security.authz.store.NativeRolesStore; import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore; @@ -46,7 +45,7 @@ public class TransportGetRolesAction extends HandledTransportAction { @@ -31,7 +31,7 @@ public class TransportPutRoleAction extends HandledTransportAction listener) { final String name = request.roleDescriptor().getName(); - if (ClientReservedRoles.isReserved(name)) { + if (ReservedRolesStore.isReserved(name)) { listener.onFailure(new IllegalArgumentException("role [" + name + "] is reserved and cannot be modified.")); return; } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportDeleteRoleMappingAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportDeleteRoleMappingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportDeleteRoleMappingAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportDeleteRoleMappingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportRefreshTokenAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportRefreshTokenAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/token/TransportRefreshTokenAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/token/TransportRefreshTokenAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportPutUserAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportPutUserAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportPutUserAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportPutUserAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditLevel.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditLevel.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditLevel.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditLevel.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrail.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrail.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrail.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrail.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrailService.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrailService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrailService.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditTrailService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java index adccc907b0b..68bbbef6e24 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java @@ -45,6 +45,7 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportMessage; import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.audit.AuditLevel; import org.elasticsearch.xpack.security.audit.AuditTrail; import org.elasticsearch.xpack.security.authc.AuthenticationToken; @@ -105,7 +106,6 @@ import static org.elasticsearch.xpack.security.audit.index.IndexNameResolver.res public class IndexAuditTrail extends AbstractComponent implements AuditTrail { public static final String NAME = "index"; - public static final String INDEX_NAME_PREFIX = ".security_audit_log"; public static final String DOC_TYPE = "doc"; public static final String INDEX_TEMPLATE_NAME = "security_audit_log"; @@ -256,7 +256,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { } private String getIndexName() { - return resolve(INDEX_NAME_PREFIX, DateTime.now(DateTimeZone.UTC), rollover); + return resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, DateTime.now(DateTimeZone.UTC), rollover); } /** @@ -888,7 +888,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { } else { dateTime = DateTime.now(DateTimeZone.UTC); } - final String index = resolve(INDEX_NAME_PREFIX, dateTime, rollover); + final String index = resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, dateTime, rollover); checkIfCurrentIndexExists(index, request, listener); } else { listener.onFailure(new IllegalStateException("failed to put index template for audit logging")); @@ -960,7 +960,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { // method for testing to allow different plugins such as mock transport... List> remoteTransportClientPlugins() { - return Collections.singletonList(XPackPlugin.class); + return Arrays.asList(Security.class, XPackPlugin.class); } public static void registerSettings(List> settings) { @@ -1010,7 +1010,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { break; } final IndexRequest indexRequest = client.prepareIndex() - .setIndex(resolve(INDEX_NAME_PREFIX, message.timestamp, rollover)) + .setIndex(resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, message.timestamp, rollover)) .setType(DOC_TYPE).setSource(message.builder).request(); bulkProcessor.add(indexRequest); } catch (InterruptedException e) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexNameResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexNameResolver.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexNameResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexNameResolver.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/AuthenticationService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java similarity index 74% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java index 6aaff01561a..8ebf8190f7e 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/InternalRealms.java @@ -15,18 +15,21 @@ import java.util.Map; import java.util.Set; import org.elasticsearch.bootstrap.BootstrapCheck; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.security.SecurityLifecycleService; import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; import org.elasticsearch.xpack.security.authc.ldap.LdapRealm; +import org.elasticsearch.xpack.security.authc.ldap.LdapRealmSettings; import org.elasticsearch.xpack.security.authc.pki.PkiRealm; +import org.elasticsearch.xpack.security.authc.pki.PkiRealmSettings; import org.elasticsearch.xpack.security.authc.support.RoleMappingFileBootstrapCheck; import org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore; import org.elasticsearch.xpack.ssl.SSLService; @@ -42,7 +45,7 @@ public class InternalRealms { * The list of all internal realm types, excluding {@link ReservedRealm#TYPE}. */ private static final Set TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( - NativeRealm.TYPE, FileRealm.TYPE, LdapRealm.AD_TYPE, LdapRealm.LDAP_TYPE, PkiRealm.TYPE + NativeRealmSettings.TYPE, FileRealmSettings.TYPE, LdapRealmSettings.AD_TYPE, LdapRealmSettings.LDAP_TYPE, PkiRealmSettings.TYPE ))); /** @@ -70,32 +73,17 @@ public class InternalRealms { SecurityLifecycleService securityLifecycleService) { Map map = new HashMap<>(); - map.put(FileRealm.TYPE, config -> new FileRealm(config, resourceWatcherService)); - map.put(NativeRealm.TYPE, config -> { + map.put(FileRealmSettings.TYPE, config -> new FileRealm(config, resourceWatcherService)); + map.put(NativeRealmSettings.TYPE, config -> { final NativeRealm nativeRealm = new NativeRealm(config, nativeUsersStore); securityLifecycleService.addSecurityIndexHealthChangeListener(nativeRealm::onSecurityIndexHealthChange); return nativeRealm; }); - map.put(LdapRealm.AD_TYPE, config -> new LdapRealm(LdapRealm.AD_TYPE, config, sslService, + map.put(LdapRealmSettings.AD_TYPE, config -> new LdapRealm(LdapRealmSettings.AD_TYPE, config, sslService, resourceWatcherService, nativeRoleMappingStore, threadPool)); - map.put(LdapRealm.LDAP_TYPE, config -> new LdapRealm(LdapRealm.LDAP_TYPE, config, + map.put(LdapRealmSettings.LDAP_TYPE, config -> new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, sslService, resourceWatcherService, nativeRoleMappingStore, threadPool)); - map.put(PkiRealm.TYPE, config -> new PkiRealm(config, resourceWatcherService, nativeRoleMappingStore)); - return Collections.unmodifiableMap(map); - } - - /** - * Provides the {@link Setting setting configuration} for each internal realm type. - * This excludes the {@link ReservedRealm}, as it cannot be configured dynamically. - * @return A map from realm-type to a collection of Setting objects. - */ - public static Map>> getSettings() { - Map>> map = new HashMap<>(); - map.put(FileRealm.TYPE, FileRealm.getSettings()); - map.put(NativeRealm.TYPE, NativeRealm.getSettings()); - map.put(LdapRealm.AD_TYPE, LdapRealm.getSettings(LdapRealm.AD_TYPE)); - map.put(LdapRealm.LDAP_TYPE, LdapRealm.getSettings(LdapRealm.LDAP_TYPE)); - map.put(PkiRealm.TYPE, PkiRealm.getSettings()); + map.put(PkiRealmSettings.TYPE, config -> new PkiRealm(config, resourceWatcherService, nativeRoleMappingStore)); return Collections.unmodifiableMap(map); } @@ -108,9 +96,9 @@ public class InternalRealms { settingsByRealm.forEach((name, settings) -> { final RealmConfig realmConfig = new RealmConfig(name, settings, globalSettings, env, null); switch (realmConfig.type()) { - case LdapRealm.AD_TYPE: - case LdapRealm.LDAP_TYPE: - case PkiRealm.TYPE: + case LdapRealmSettings.AD_TYPE: + case LdapRealmSettings.LDAP_TYPE: + case PkiRealmSettings.TYPE: final BootstrapCheck check = RoleMappingFileBootstrapCheck.create(realmConfig); if (check != null) { checks.add(check); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java similarity index 93% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java index b91d44d3120..24395009fd8 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java @@ -23,9 +23,9 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.Environment; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState.AllowedRealmType; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; -import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; /** @@ -65,7 +65,7 @@ public class Realms extends AbstractComponent implements Iterable { internalRealms.add(realm); } - if (FileRealm.TYPE.equals(realm.type()) || NativeRealm.TYPE.equals(realm.type())) { + if (FileRealmSettings.TYPE.equals(realm.type()) || NativeRealmSettings.TYPE.equals(realm.type())) { nativeRealms.add(realm); } } @@ -123,7 +123,7 @@ public class Realms extends AbstractComponent implements Iterable { public Realm realm(String name) { for (Realm realm : realms) { - if (name.equals(realm.config.name)) { + if (name.equals(realm.name())) { return realm; } } @@ -155,7 +155,7 @@ public class Realms extends AbstractComponent implements Iterable { } continue; } - if (FileRealm.TYPE.equals(type) || NativeRealm.TYPE.equals(type)) { + if (FileRealmSettings.TYPE.equals(type) || NativeRealmSettings.TYPE.equals(type)) { // this is an internal realm factory, let's make sure we didn't already registered one // (there can only be one instance of an internal realm) if (internalTypes.contains(type)) { @@ -221,14 +221,16 @@ public class Realms extends AbstractComponent implements Iterable { } private void addNativeRealms(List realms) throws Exception { - Realm.Factory fileRealm = factories.get(FileRealm.TYPE); + Realm.Factory fileRealm = factories.get(FileRealmSettings.TYPE); if (fileRealm != null) { - realms.add(fileRealm.create(new RealmConfig("default_" + FileRealm.TYPE, Settings.EMPTY, settings, env, threadContext))); + realms.add(fileRealm.create(new RealmConfig("default_" + FileRealmSettings.TYPE, Settings.EMPTY, + settings, env, threadContext))); } - Realm.Factory indexRealmFactory = factories.get(NativeRealm.TYPE); + Realm.Factory indexRealmFactory = factories.get(NativeRealmSettings.TYPE); if (indexRealmFactory != null) { - realms.add(indexRealmFactory.create(new RealmConfig("default_" + NativeRealm.TYPE, Settings.EMPTY, settings, env, threadContext))); + realms.add(indexRealmFactory.create(new RealmConfig("default_" + NativeRealmSettings.TYPE, Settings.EMPTY, + settings, env, threadContext))); } } @@ -261,7 +263,7 @@ public class Realms extends AbstractComponent implements Iterable { case NONE: return false; case NATIVE: - return FileRealm.TYPE.equals(type) || NativeRealm.TYPE.equals(type); + return FileRealmSettings.TYPE.equals(type) || NativeRealmSettings.TYPE.equals(type); case DEFAULT: return InternalRealms.isInternalRealm(type, true); default: diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java similarity index 96% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index 782b90b1a1d..845b184fcbc 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -47,7 +47,6 @@ import org.elasticsearch.common.io.stream.InputStreamStreamInput; import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -63,7 +62,7 @@ import org.elasticsearch.index.engine.VersionConflictEngineException; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.SecurityLifecycleService; import javax.crypto.Cipher; @@ -129,13 +128,13 @@ public final class TokenService extends AbstractComponent { private static final int IV_BYTES = 12; private static final int VERSION_BYTES = 4; private static final String ENCRYPTION_CIPHER = "AES/GCM/NoPadding"; - private static final String EXPIRED_TOKEN_WWW_AUTH_VALUE = "Bearer realm=\"" + XpackField.SECURITY + + private static final String EXPIRED_TOKEN_WWW_AUTH_VALUE = "Bearer realm=\"" + XPackField.SECURITY + "\", error=\"invalid_token\", error_description=\"The access token expired\""; - private static final String MALFORMED_TOKEN_WWW_AUTH_VALUE = "Bearer realm=\"" + XpackField.SECURITY + + private static final String MALFORMED_TOKEN_WWW_AUTH_VALUE = "Bearer realm=\"" + XPackField.SECURITY + "\", error=\"invalid_token\", error_description=\"The access token is malformed\""; private static final String TYPE = "doc"; - public static final String THREAD_POOL_NAME = XpackField.SECURITY + "-token-key"; + public static final String THREAD_POOL_NAME = XPackField.SECURITY + "-token-key"; public static final Setting TOKEN_EXPIRATION = Setting.timeSetting("xpack.security.authc.token.timeout", TimeValue.timeValueMinutes(20L), TimeValue.timeValueSeconds(1L), Property.NodeScope); public static final Setting DELETE_INTERVAL = Setting.timeSetting("xpack.security.authc.token.delete.interval", @@ -1016,7 +1015,7 @@ public final class TokenService extends AbstractComponent { * this method doesn't modify the metadata used in this token service. See {@link #refreshMetaData(TokenMetaData)} */ synchronized TokenMetaData generateSpareKey() { - KeyAndCache maxKey = keyCache.cache.values().stream().max(Comparator.comparingLong(v -> v.keyAndTimestamp.timestamp)).get(); + KeyAndCache maxKey = keyCache.cache.values().stream().max(Comparator.comparingLong(v -> v.keyAndTimestamp.getTimestamp())).get(); KeyAndCache currentKey = keyCache.activeKeyCache; if (currentKey == maxKey) { long timestamp = createdTimeStamps.incrementAndGet(); @@ -1039,7 +1038,7 @@ public final class TokenService extends AbstractComponent { * Rotate the current active key to the spare key created in the previous {@link #generateSpareKey()} call. */ synchronized TokenMetaData rotateToSpareKey() { - KeyAndCache maxKey = keyCache.cache.values().stream().max(Comparator.comparingLong(v -> v.keyAndTimestamp.timestamp)).get(); + KeyAndCache maxKey = keyCache.cache.values().stream().max(Comparator.comparingLong(v -> v.keyAndTimestamp.getTimestamp())).get(); if (maxKey == keyCache.activeKeyCache) { throw new IllegalStateException("call generateSpareKey first"); } @@ -1058,10 +1057,10 @@ public final class TokenService extends AbstractComponent { KeyAndCache currentKey = keyCache.get(keyCache.currentTokenKeyHash); ArrayList entries = new ArrayList<>(keyCache.cache.values()); Collections.sort(entries, - (left, right) -> Long.compare(right.keyAndTimestamp.timestamp, left.keyAndTimestamp.timestamp)); + (left, right) -> Long.compare(right.keyAndTimestamp.getTimestamp(), left.keyAndTimestamp.getTimestamp())); for (KeyAndCache value: entries) { - if (map.size() < numKeysToKeep || value.keyAndTimestamp.timestamp >= currentKey - .keyAndTimestamp.timestamp) { + if (map.size() < numKeysToKeep || value.keyAndTimestamp.getTimestamp()>= currentKey + .keyAndTimestamp.getTimestamp()) { logger.debug("keeping key {} ", value.getKeyHash()); map.put(value.getKeyHash(), value); } else { @@ -1092,14 +1091,14 @@ public final class TokenService extends AbstractComponent { * Refreshes the current in-use metadata. */ synchronized void refreshMetaData(TokenMetaData metaData) { - BytesKey currentUsedKeyHash = new BytesKey(metaData.currentKeyHash); + BytesKey currentUsedKeyHash = new BytesKey(metaData.getCurrentKeyHash()); byte[] saltArr = new byte[SALT_BYTES]; - Map map = new HashMap<>(metaData.keys.size()); + Map map = new HashMap<>(metaData.getKeys().size()); long maxTimestamp = createdTimeStamps.get(); - for (KeyAndTimestamp key : metaData.keys) { + for (KeyAndTimestamp key : metaData.getKeys()) { secureRandom.nextBytes(saltArr); KeyAndCache keyAndCache = new KeyAndCache(key, new BytesKey(saltArr)); - maxTimestamp = Math.max(keyAndCache.keyAndTimestamp.timestamp, maxTimestamp); + maxTimestamp = Math.max(keyAndCache.keyAndTimestamp.getTimestamp(), maxTimestamp); if (keyCache.cache.containsKey(keyAndCache.getKeyHash()) == false) { map.put(keyAndCache.getKeyHash(), keyAndCache); } else { @@ -1213,50 +1212,6 @@ public final class TokenService extends AbstractComponent { this.keyCache.activeKeyCache.keyCache.invalidateAll(); } - static final class KeyAndTimestamp implements Writeable { - private final SecureString key; - private final long timestamp; - - private KeyAndTimestamp(SecureString key, long timestamp) { - this.key = key; - this.timestamp = timestamp; - } - - KeyAndTimestamp(StreamInput input) throws IOException { - timestamp = input.readVLong(); - byte[] keyBytes = input.readByteArray(); - final char[] ref = new char[keyBytes.length]; - int len = UnicodeUtil.UTF8toUTF16(keyBytes, 0, keyBytes.length, ref); - key = new SecureString(Arrays.copyOfRange(ref, 0, len)); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeVLong(timestamp); - BytesRef bytesRef = new BytesRef(key); - out.writeVInt(bytesRef.length); - out.writeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - KeyAndTimestamp that = (KeyAndTimestamp) o; - - if (timestamp != that.timestamp) return false; - return key.equals(that.key); - } - - @Override - public int hashCode() { - int result = key.hashCode(); - result = 31 * result + (int) (timestamp ^ (timestamp >>> 32)); - return result; - } - } - static final class KeyAndCache implements Closeable { private final KeyAndTimestamp keyAndTimestamp; private final Cache keyCache; @@ -1270,13 +1225,13 @@ public final class TokenService extends AbstractComponent { .setMaximumWeight(500L) .build(); try { - SecretKey secretKey = computeSecretKey(keyAndTimestamp.key.getChars(), salt.bytes); + SecretKey secretKey = computeSecretKey(keyAndTimestamp.getKey().getChars(), salt.bytes); keyCache.put(salt, secretKey); } catch (Exception e) { throw new IllegalStateException(e); } this.salt = salt; - this.keyHash = calculateKeyHash(keyAndTimestamp.key); + this.keyHash = calculateKeyHash(keyAndTimestamp.getKey()); } private SecretKey getKey(BytesKey salt) { @@ -1285,15 +1240,15 @@ public final class TokenService extends AbstractComponent { public SecretKey getOrComputeKey(BytesKey decodedSalt) throws ExecutionException { return keyCache.computeIfAbsent(decodedSalt, (salt) -> { - try (SecureString closeableChars = keyAndTimestamp.key.clone()) { + try (SecureString closeableChars = keyAndTimestamp.getKey().clone()) { return computeSecretKey(closeableChars.getChars(), salt.bytes); } }); } @Override - public void close() { - keyAndTimestamp.key.close(); + public void close() throws IOException { + keyAndTimestamp.getKey().close(); } BytesKey getKeyHash() { @@ -1327,7 +1282,7 @@ public final class TokenService extends AbstractComponent { final Map cache; final BytesKey currentTokenKeyHash; final KeyAndCache activeKeyCache; - + private TokenKeys(Map cache, BytesKey currentTokenKeyHash) { this.cache = cache; this.currentTokenKeyHash = currentTokenKeyHash; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/UserToken.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/UserToken.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/UserToken.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/UserToken.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateTool.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateTool.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateTool.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateTool.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java similarity index 85% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java index 85c7aa11e21..a733d52c308 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealm.java @@ -8,26 +8,21 @@ package org.elasticsearch.xpack.security.authc.esnative; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterIndexHealth; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.RealmConfig; import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.user.User; -import java.util.Set; - /** * User/password realm that is backed by an Elasticsearch index */ public class NativeRealm extends CachingUsernamePasswordRealm { - public static final String TYPE = "native"; - private final NativeUsersStore userStore; public NativeRealm(RealmConfig config, NativeUsersStore usersStore) { - super(TYPE, config); + super(NativeRealmSettings.TYPE, config); this.userStore = usersStore; } @@ -56,10 +51,4 @@ public class NativeRealm extends CachingUsernamePasswordRealm { expireAll(); } - /** - * @return The {@link Setting setting configuration} for this realm type - */ - public static Set> getSettings() { - return CachingUsernamePasswordRealm.getCachingSettings(); - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/UserAndPassword.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/UserAndPassword.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/UserAndPassword.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/UserAndPassword.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java similarity index 87% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java index c49dd3c1242..ad924fcc8fc 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileRealm.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.security.authc.file; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.RealmConfig; @@ -15,12 +14,9 @@ import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.user.User; import java.util.Map; -import java.util.Set; public class FileRealm extends CachingUsernamePasswordRealm { - public static final String TYPE = "file"; - private final FileUserPasswdStore userPasswdStore; private final FileUserRolesStore userRolesStore; @@ -30,7 +26,7 @@ public class FileRealm extends CachingUsernamePasswordRealm { // pkg private for testing FileRealm(RealmConfig config, FileUserPasswdStore userPasswdStore, FileUserRolesStore userRolesStore) { - super(TYPE, config); + super(FileRealmSettings.TYPE, config); this.userPasswdStore = userPasswdStore; userPasswdStore.addListener(this::expireAll); this.userRolesStore = userRolesStore; @@ -64,10 +60,4 @@ public class FileRealm extends CachingUsernamePasswordRealm { return stats; } - /** - * @return The {@link Setting setting configuration} for this realm type - */ - public static Set> getSettings() { - return CachingUsernamePasswordRealm.getCachingSettings(); - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java index 1f25f403753..31d5dc62c53 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.env.Environment; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.authc.file.FileUserPasswdStore; import org.elasticsearch.xpack.security.authc.file.FileUserRolesStore; import org.elasticsearch.xpack.security.authc.support.Hasher; @@ -497,7 +497,7 @@ public class UsersTool extends LoggingAwareMultiCommand { * Ensure the X-Pack configuration directory exists as a child of $ES_CONF_DIR or return a helpful error message. */ private void checkConfigurationDir(Environment env) throws Exception { - Path configDir = env.configFile().resolve(XpackField.NAME); + Path configDir = env.configFile().resolve(XPackField.NAME); if (Files.exists(configDir) == false) { throw new UserException(ExitCodes.CONFIG, String.format(Locale.ROOT, "Directory %s does not exist. Please ensure " + diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java index 506454a8a22..75ee4f43e3c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolver.java @@ -24,12 +24,12 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import static org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.AD_DOMAIN_NAME_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING; import static org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.buildDnFromDomain; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.OBJECT_CLASS_PRESENCE_FILTER; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.search; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.searchForEntry; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.IGNORE_REFERRAL_ERRORS_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING; class ActiveDirectoryGroupsResolver implements GroupsResolver { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java similarity index 87% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java index dc7470d2f16..37cf04663b1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java @@ -22,7 +22,6 @@ import org.elasticsearch.common.cache.Cache; import org.elasticsearch.common.cache.CacheBuilder; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; @@ -34,15 +33,12 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession.GroupsResolver; import org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils; -import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.xpack.security.authc.support.CharArrays; import org.elasticsearch.xpack.ssl.SSLService; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.concurrent.ExecutionException; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.attributesToSearchFor; @@ -58,43 +54,36 @@ import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.sear */ class ActiveDirectorySessionFactory extends PoolingSessionFactory { - 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"; private static final String NETBIOS_NAME_FILTER_TEMPLATE = "(netbiosname={0})"; - static final Setting POOL_ENABLED = Setting.boolSetting("user_search.pool.enabled", - settings -> Boolean.toString(PoolingSessionFactory.BIND_DN.exists(settings)), Setting.Property.NodeScope); final DefaultADAuthenticator defaultADAuthenticator; final DownLevelADAuthenticator downLevelADAuthenticator; final UpnADAuthenticator upnADAuthenticator; ActiveDirectorySessionFactory(RealmConfig config, SSLService sslService, ThreadPool threadPool) throws LDAPException { - super(config, sslService, new ActiveDirectoryGroupsResolver(config.settings()), POOL_ENABLED, () -> { - if (BIND_DN.exists(config.settings())) { - return new SimpleBindRequest(getBindDN(config.settings()), BIND_PASSWORD.get(config.settings())); + super(config, sslService, new ActiveDirectoryGroupsResolver(config.settings()), + ActiveDirectorySessionFactorySettings.POOL_ENABLED, () -> { + if (PoolingSessionFactorySettings.BIND_DN.exists(config.settings())) { + return new SimpleBindRequest(getBindDN(config.settings()), + PoolingSessionFactorySettings.BIND_PASSWORD.get(config.settings())); } else { return new SimpleBindRequest(); } }, () -> { - if (BIND_DN.exists(config.settings())) { - final String healthCheckDn = BIND_DN.get(config.settings()); + if (PoolingSessionFactorySettings.BIND_DN.exists(config.settings())) { + final String healthCheckDn = PoolingSessionFactorySettings.BIND_DN.get(config.settings()); if (healthCheckDn.isEmpty() && healthCheckDn.indexOf('=') > 0) { return healthCheckDn; } } - return config.settings().get(AD_USER_SEARCH_BASEDN_SETTING, config.settings().get(AD_DOMAIN_NAME_SETTING)); + return config.settings().get(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_BASEDN_SETTING, + config.settings().get(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING)); }, threadPool); Settings settings = config.settings(); - String domainName = settings.get(AD_DOMAIN_NAME_SETTING); + String domainName = settings.get(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING); if (domainName == null) { - throw new IllegalArgumentException("missing [" + AD_DOMAIN_NAME_SETTING + "] setting for active directory"); + throw new IllegalArgumentException("missing [" + ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING + + "] setting for active directory"); } String domainDN = buildDnFromDomain(domainName); defaultADAuthenticator = new DefaultADAuthenticator(config, timeout, ignoreReferralErrors, logger, groupResolver, @@ -108,7 +97,7 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { @Override protected List getDefaultLdapUrls(Settings settings) { - return Collections.singletonList("ldap://" + settings.get(AD_DOMAIN_NAME_SETTING) + ":389"); + return Collections.singletonList("ldap://" + settings.get(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING) + ":389"); } @Override @@ -150,13 +139,14 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { @Override void getUnauthenticatedSessionWithoutPool(String user, ActionListener listener) { - if (BIND_DN.exists(config.settings()) == false) { + if (PoolingSessionFactorySettings.BIND_DN.exists(config.settings()) == false) { listener.onResponse(null); return; } try { final LDAPConnection connection = LdapUtils.privilegedConnect(serverSet::getConnection); - final SimpleBindRequest bind = new SimpleBindRequest(getBindDN(config.settings()), BIND_PASSWORD.get(config.settings())); + final SimpleBindRequest bind = new SimpleBindRequest(getBindDN(config.settings()), + PoolingSessionFactorySettings.BIND_PASSWORD.get(config.settings())); LdapUtils.maybeForkThenBind(connection, bind, threadPool, new AbstractRunnable() { @Override @@ -197,29 +187,13 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { } static String getBindDN(Settings settings) { - String bindDN = BIND_DN.get(settings); + String bindDN = PoolingSessionFactorySettings.BIND_DN.get(settings); if (bindDN.isEmpty() == false && bindDN.indexOf('\\') < 0 && bindDN.indexOf('@') < 0 && bindDN.indexOf('=') < 0) { - bindDN = bindDN + "@" + settings.get(AD_DOMAIN_NAME_SETTING); + bindDN = bindDN + "@" + settings.get(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING); } return bindDN; } - public static Set> getSettings() { - Set> settings = new HashSet<>(); - settings.addAll(SessionFactory.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(PoolingSessionFactory.getSettings()); - return settings; - } - ADAuthenticator getADAuthenticator(String username) { if (username.indexOf('\\') > 0) { return downLevelADAuthenticator; @@ -255,10 +229,11 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { this.metaDataResolver = metaDataResolver; final Settings settings = realm.settings(); this.bindDN = getBindDN(settings); - this.bindPassword = BIND_PASSWORD.get(settings); + this.bindPassword = PoolingSessionFactorySettings.BIND_PASSWORD.get(settings); this.threadPool = threadPool; - userSearchDN = settings.get(AD_USER_SEARCH_BASEDN_SETTING, domainDN); - userSearchScope = LdapSearchScope.resolve(settings.get(AD_USER_SEARCH_SCOPE_SETTING), LdapSearchScope.SUB_TREE); + userSearchDN = settings.get(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_BASEDN_SETTING, domainDN); + userSearchScope = LdapSearchScope.resolve(settings.get(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_SCOPE_SETTING), + LdapSearchScope.SUB_TREE); userSearchFilter = settings.get(userSearchFilterSetting, defaultUserSearchFilter); } @@ -343,13 +318,14 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { DefaultADAuthenticator(RealmConfig realm, TimeValue timeout, boolean ignoreReferralErrors, Logger logger, GroupsResolver groupsResolver, LdapMetaDataResolver metaDataResolver, String domainDN, ThreadPool threadPool) { - super(realm, timeout, ignoreReferralErrors, logger, groupsResolver, metaDataResolver, domainDN, AD_USER_SEARCH_FILTER_SETTING, + super(realm, timeout, ignoreReferralErrors, logger, groupsResolver, metaDataResolver, domainDN, + ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_FILTER_SETTING, "(&(objectClass=user)(|(sAMAccountName={0})(userPrincipalName={0}@" + domainName(realm) + ")))", threadPool); domainName = domainName(realm); } private static String domainName(RealmConfig realm) { - return realm.settings().get(AD_DOMAIN_NAME_SETTING); + return realm.settings().get(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING); } @Override @@ -388,7 +364,7 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { GroupsResolver groupsResolver, LdapMetaDataResolver metaDataResolver, String domainDN, SSLService sslService, ThreadPool threadPool) { super(config, timeout, ignoreReferralErrors, logger, groupsResolver, metaDataResolver, domainDN, - AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING, DOWN_LEVEL_FILTER, threadPool); + ActiveDirectorySessionFactorySettings.AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING, DOWN_LEVEL_FILTER, threadPool); this.domainDN = domainDN; this.settings = config.settings(); this.sslService = sslService; @@ -528,10 +504,10 @@ class ActiveDirectorySessionFactory extends PoolingSessionFactory { UpnADAuthenticator(RealmConfig config, TimeValue timeout, boolean ignoreReferralErrors, Logger logger, GroupsResolver groupsResolver, LdapMetaDataResolver metaDataResolver, String domainDN, ThreadPool threadPool) { super(config, timeout, ignoreReferralErrors, logger, groupsResolver, metaDataResolver, domainDN, - AD_UPN_USER_SEARCH_FILTER_SETTING, UPN_USER_FILTER, threadPool); + ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING, UPN_USER_FILTER, threadPool); if (userSearchFilter.contains("{0}")) { new DeprecationLogger(logger).deprecated("The use of the account name variable {0} in the setting [" - + RealmSettings.getFullSettingKey(config, AD_UPN_USER_SEARCH_FILTER_SETTING) + + + RealmSettings.getFullSettingKey(config, ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING) + "] has been deprecated and will be removed in a future version!"); } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java similarity index 88% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java index 147cede27e9..bc0a5608b6e 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealm.java @@ -5,10 +5,8 @@ */ package org.elasticsearch.xpack.security.authc.ldap; -import java.util.HashSet; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Function; @@ -22,8 +20,6 @@ import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ContextPreservingActionListener; import org.elasticsearch.common.collect.MapBuilder; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -34,7 +30,6 @@ import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.RealmConfig; import org.elasticsearch.xpack.security.authc.RealmSettings; import org.elasticsearch.xpack.security.authc.ldap.support.LdapLoadBalancing; -import org.elasticsearch.xpack.security.authc.ldap.support.LdapMetaDataResolver; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm; @@ -52,11 +47,6 @@ import org.elasticsearch.xpack.ssl.SSLService; */ public final class LdapRealm extends CachingUsernamePasswordRealm { - 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), Property.NodeScope); - private final SessionFactory sessionFactory; private final UserRoleMapper roleMapper; private final ThreadPool threadPool; @@ -79,7 +69,7 @@ public final class LdapRealm extends CachingUsernamePasswordRealm { this.sessionFactory = sessionFactory; this.roleMapper = roleMapper; this.threadPool = threadPool; - this.executionTimeout = EXECUTION_TIMEOUT.get(config.settings()); + this.executionTimeout = LdapRealmSettings.EXECUTION_TIMEOUT.get(config.settings()); roleMapper.refreshRealmOnChange(this); } @@ -87,18 +77,19 @@ public final class LdapRealm extends CachingUsernamePasswordRealm { throws LDAPException { final SessionFactory sessionFactory; - if (AD_TYPE.equals(type)) { + if (LdapRealmSettings.AD_TYPE.equals(type)) { sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); } else { - assert LDAP_TYPE.equals(type) : "type [" + type + "] is unknown. expected one of [" + AD_TYPE + ", " + LDAP_TYPE + "]"; + assert LdapRealmSettings.LDAP_TYPE.equals(type) : "type [" + type + "] is unknown. expected one of [" + + LdapRealmSettings.AD_TYPE + ", " + LdapRealmSettings.LDAP_TYPE + "]"; final boolean hasSearchSettings = LdapUserSearchSessionFactory.hasUserSearchSettings(config); - final boolean hasTemplates = LdapSessionFactory.USER_DN_TEMPLATES_SETTING.exists(config.settings()); + final boolean hasTemplates = LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING.exists(config.settings()); if (hasSearchSettings == false) { if (hasTemplates == false) { throw new IllegalArgumentException("settings were not found for either user search [" + RealmSettings.getFullSettingKey(config, LdapUserSearchSessionFactory.SEARCH_PREFIX) + "] or user template [" + - RealmSettings.getFullSettingKey(config, LdapSessionFactory.USER_DN_TEMPLATES_SETTING) + + RealmSettings.getFullSettingKey(config, LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING) + "] modes of operation. " + "Please provide the settings for the mode you wish to use. For more details refer to the ldap " + "authentication section of the X-Pack guide."); @@ -108,7 +99,7 @@ public final class LdapRealm extends CachingUsernamePasswordRealm { throw new IllegalArgumentException("settings were found for both user search [" + RealmSettings.getFullSettingKey(config, LdapUserSearchSessionFactory.SEARCH_PREFIX) + "] and user template [" + - RealmSettings.getFullSettingKey(config, LdapSessionFactory.USER_DN_TEMPLATES_SETTING) + + RealmSettings.getFullSettingKey(config, LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING) + "] modes of operation. " + "Please remove the settings for the mode you do not wish to use. For more details refer to the ldap " + "authentication section of the X-Pack guide."); @@ -119,26 +110,6 @@ public final class LdapRealm extends CachingUsernamePasswordRealm { return sessionFactory; } - /** - * @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(CachingUsernamePasswordRealm.getCachingSettings()); - settings.addAll(CompositeRoleMapper.getSettings()); - settings.add(EXECUTION_TIMEOUT); - if (AD_TYPE.equals(type)) { - settings.addAll(ActiveDirectorySessionFactory.getSettings()); - } else { - assert LDAP_TYPE.equals(type) : "type [" + type + "] is unknown. expected one of [" + AD_TYPE + ", " + LDAP_TYPE + "]"; - settings.addAll(LdapSessionFactory.getSettings()); - settings.addAll(LdapUserSearchSessionFactory.getSettings()); - } - settings.addAll(LdapMetaDataResolver.getSettings()); - return settings; - } - /** * Given a username and password, open a connection to ldap, bind to authenticate, retrieve groups, map to roles and build the user. * This user will then be passed to the listener diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java similarity index 86% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java index 3a3a10dfd5d..b1ed70e41f1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactory.java @@ -13,7 +13,6 @@ import org.apache.lucene.util.IOUtils; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.threadpool.ThreadPool; @@ -28,13 +27,7 @@ import org.elasticsearch.xpack.security.authc.support.CharArrays; import org.elasticsearch.xpack.ssl.SSLService; import java.text.MessageFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; import java.util.Locale; -import java.util.Set; -import java.util.function.Function; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.escapedRDNValue; @@ -46,9 +39,6 @@ import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.esca */ public class LdapSessionFactory extends SessionFactory { - public static final Setting> USER_DN_TEMPLATES_SETTING = Setting.listSetting("user_dn_templates", - Collections.emptyList(), Function.identity(), Setting.Property.NodeScope); - private final String[] userDnTemplates; private final GroupsResolver groupResolver; private final LdapMetaDataResolver metaDataResolver; @@ -56,10 +46,10 @@ public class LdapSessionFactory extends SessionFactory { public LdapSessionFactory(RealmConfig config, SSLService sslService, ThreadPool threadPool) { super(config, sslService, threadPool); Settings settings = config.settings(); - userDnTemplates = USER_DN_TEMPLATES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); + userDnTemplates = LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); if (userDnTemplates.length == 0) { throw new IllegalArgumentException("missing required LDAP setting [" - + RealmSettings.getFullSettingKey(config, USER_DN_TEMPLATES_SETTING) + "]"); + + RealmSettings.getFullSettingKey(config, LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING) + "]"); } logger.info("Realm [{}] is in user-dn-template mode: [{}]", config.name(), userDnTemplates); groupResolver = groupResolver(settings); @@ -133,16 +123,10 @@ public class LdapSessionFactory extends SessionFactory { } static GroupsResolver groupResolver(Settings settings) { - if (SearchGroupsResolver.BASE_DN.exists(settings)) { + if (SearchGroupsResolverSettings.BASE_DN.exists(settings)) { return new SearchGroupsResolver(settings); } return new UserAttributeGroupsResolver(settings); } - public static Set> getSettings() { - Set> settings = new HashSet<>(); - settings.addAll(SessionFactory.getSettings()); - settings.add(USER_DN_TEMPLATES_SETTING); - return settings; - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java similarity index 79% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java index cb76c08969c..cb8ed1afc35 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactory.java @@ -16,7 +16,6 @@ import org.apache.lucene.util.IOUtils; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.threadpool.ThreadPool; @@ -26,61 +25,48 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession.GroupsResolver; import org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils; -import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.xpack.security.authc.support.CharArrays; import org.elasticsearch.xpack.ssl.SSLService; -import java.util.HashSet; -import java.util.Set; -import java.util.function.Function; - import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.attributesToSearchFor; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.createFilter; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.searchForEntry; class LdapUserSearchSessionFactory extends PoolingSessionFactory { - private static final String DEFAULT_USERNAME_ATTRIBUTE = "uid"; - static final String SEARCH_PREFIX = "user_search."; - static final Setting SEARCH_ATTRIBUTE = new Setting<>("user_search.attribute", DEFAULT_USERNAME_ATTRIBUTE, - Function.identity(), Setting.Property.NodeScope, Setting.Property.Deprecated); - - private static final Setting SEARCH_BASE_DN = Setting.simpleString("user_search.base_dn", Setting.Property.NodeScope); - private static final Setting SEARCH_FILTER = Setting.simpleString("user_search.filter", Setting.Property.NodeScope); - private static final Setting SEARCH_SCOPE = new Setting<>("user_search.scope", (String) null, - s -> LdapSearchScope.resolve(s, LdapSearchScope.SUB_TREE), Setting.Property.NodeScope); - private static final Setting POOL_ENABLED = Setting.boolSetting("user_search.pool.enabled", true, Setting.Property.NodeScope); private final String userSearchBaseDn; private final LdapSearchScope scope; private final String searchFilter; LdapUserSearchSessionFactory(RealmConfig config, SSLService sslService, ThreadPool threadPool) throws LDAPException { - super(config, sslService, groupResolver(config.settings()), POOL_ENABLED, + super(config, sslService, groupResolver(config.settings()), LdapUserSearchSessionFactorySettings.POOL_ENABLED, () -> LdapUserSearchSessionFactory.bindRequest(config.settings()), () -> { - if (BIND_DN.exists(config.settings())) { - return BIND_DN.get(config.settings()); + if (PoolingSessionFactorySettings.BIND_DN.exists(config.settings())) { + return PoolingSessionFactorySettings.BIND_DN.get(config.settings()); } else { - return SEARCH_BASE_DN.get(config.settings()); + return LdapUserSearchSessionFactorySettings.SEARCH_BASE_DN.get(config.settings()); } }, threadPool); Settings settings = config.settings(); - if (SEARCH_BASE_DN.exists(settings)) { - userSearchBaseDn = SEARCH_BASE_DN.get(settings); + if (LdapUserSearchSessionFactorySettings.SEARCH_BASE_DN.exists(settings)) { + userSearchBaseDn = LdapUserSearchSessionFactorySettings.SEARCH_BASE_DN.get(settings); } else { - throw new IllegalArgumentException("[" + RealmSettings.getFullSettingKey(config, SEARCH_BASE_DN) + "] must be specified"); + throw new IllegalArgumentException("[" + RealmSettings.getFullSettingKey(config, + LdapUserSearchSessionFactorySettings.SEARCH_BASE_DN) + "] must be specified"); } - scope = SEARCH_SCOPE.get(settings); + scope = LdapUserSearchSessionFactorySettings.SEARCH_SCOPE.get(settings); searchFilter = getSearchFilter(config); logger.info("Realm [{}] is in user-search mode - base_dn=[{}], search filter=[{}]", config.name(), userSearchBaseDn, searchFilter); } static SimpleBindRequest bindRequest(Settings settings) { - if (BIND_DN.exists(settings)) { - return new SimpleBindRequest(BIND_DN.get(settings), BIND_PASSWORD.get(settings)); + if (PoolingSessionFactorySettings.BIND_DN.exists(settings)) { + return new SimpleBindRequest(PoolingSessionFactorySettings.BIND_DN.get(settings), + PoolingSessionFactorySettings.BIND_PASSWORD.get(settings)); } else { return new SimpleBindRequest(); } @@ -243,7 +229,7 @@ class LdapUserSearchSessionFactory extends PoolingSessionFactory { } private static GroupsResolver groupResolver(Settings settings) { - if (SearchGroupsResolver.BASE_DN.exists(settings)) { + if (SearchGroupsResolverSettings.BASE_DN.exists(settings)) { return new SearchGroupsResolver(settings); } return new UserAttributeGroupsResolver(settings); @@ -251,34 +237,22 @@ class LdapUserSearchSessionFactory extends PoolingSessionFactory { static String getSearchFilter(RealmConfig config) { final Settings settings = config.settings(); - final boolean hasAttribute = SEARCH_ATTRIBUTE.exists(settings); - final boolean hasFilter = SEARCH_FILTER.exists(settings); + final boolean hasAttribute = LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE.exists(settings); + final boolean hasFilter = LdapUserSearchSessionFactorySettings.SEARCH_FILTER.exists(settings); if (hasAttribute && hasFilter) { throw new IllegalArgumentException("search attribute setting [" + - RealmSettings.getFullSettingKey(config, SEARCH_ATTRIBUTE) + "] and filter setting [" + - RealmSettings.getFullSettingKey(config, SEARCH_FILTER) + "] cannot be combined!"); + RealmSettings.getFullSettingKey(config, LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE) + + "] and filter setting [" + + RealmSettings.getFullSettingKey(config, LdapUserSearchSessionFactorySettings.SEARCH_FILTER) + + "] cannot be combined!"); } else if (hasFilter) { - return SEARCH_FILTER.get(settings); + return LdapUserSearchSessionFactorySettings.SEARCH_FILTER.get(settings); } else if (hasAttribute) { - return "(" + SEARCH_ATTRIBUTE.get(settings) + "={0})"; + return "(" + LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE.get(settings) + "={0})"; } else { return "(uid={0})"; } } - public static Set> getSettings() { - Set> settings = new HashSet<>(); - settings.addAll(SessionFactory.getSettings()); - settings.addAll(PoolingSessionFactory.getSettings()); - settings.add(SEARCH_BASE_DN); - settings.add(SEARCH_SCOPE); - settings.add(SEARCH_ATTRIBUTE); - settings.add(POOL_ENABLED); - settings.add(SEARCH_FILTER); - settings.addAll(SearchGroupsResolver.getSettings()); - settings.addAll(UserAttributeGroupsResolver.getSettings()); - - return settings; - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java similarity index 77% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java index 8a2f9670d20..daf0aed4e49 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/PoolingSessionFactory.java @@ -19,7 +19,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.security.authc.RealmConfig; import org.elasticsearch.xpack.security.authc.RealmSettings; @@ -29,8 +28,6 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils; import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.xpack.ssl.SSLService; -import java.util.Optional; -import java.util.Set; import java.util.function.Supplier; /** @@ -38,24 +35,6 @@ import java.util.function.Supplier; */ abstract class PoolingSessionFactory extends SessionFactory implements Releasable { - static final int DEFAULT_CONNECTION_POOL_SIZE = 20; - static final int DEFAULT_CONNECTION_POOL_INITIAL_SIZE = 0; - 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); - - private static final TimeValue DEFAULT_HEALTH_CHECK_INTERVAL = TimeValue.timeValueSeconds(60L); - private static final Setting POOL_INITIAL_SIZE = Setting.intSetting("user_search.pool.initial_size", - DEFAULT_CONNECTION_POOL_INITIAL_SIZE, 0, Setting.Property.NodeScope); - private static final Setting POOL_SIZE = Setting.intSetting("user_search.pool.size", - DEFAULT_CONNECTION_POOL_SIZE, 1, Setting.Property.NodeScope); - private static final Setting HEALTH_CHECK_INTERVAL = Setting.timeSetting("user_search.pool.health_check.interval", - DEFAULT_HEALTH_CHECK_INTERVAL, Setting.Property.NodeScope); - private static final Setting HEALTH_CHECK_ENABLED = Setting.boolSetting("user_search.pool.health_check.enabled", - true, Setting.Property.NodeScope); - private static final Setting> HEALTH_CHECK_DN = new Setting<>("user_search.pool.health_check.dn", (String) null, - Optional::ofNullable, Setting.Property.NodeScope); - private final boolean useConnectionPool; private final LDAPConnectionPool connectionPool; @@ -135,16 +114,16 @@ abstract class PoolingSessionFactory extends SessionFactory implements Releasabl Supplier healthCheckDnSupplier) throws LDAPException { Settings settings = config.settings(); BindRequest bindRequest = bindRequestSupplier.get(); - final int initialSize = POOL_INITIAL_SIZE.get(settings); - final int size = POOL_SIZE.get(settings); + final int initialSize = PoolingSessionFactorySettings.POOL_INITIAL_SIZE.get(settings); + final int size = PoolingSessionFactorySettings.POOL_SIZE.get(settings); LDAPConnectionPool pool = null; boolean success = false; try { pool = LdapUtils.privilegedConnect(() -> new LDAPConnectionPool(serverSet, bindRequest, initialSize, size)); pool.setRetryFailedOperationsDueToInvalidConnections(true); - if (HEALTH_CHECK_ENABLED.get(settings)) { - String entryDn = HEALTH_CHECK_DN.get(settings).orElseGet(healthCheckDnSupplier); - final long healthCheckInterval = HEALTH_CHECK_INTERVAL.get(settings).millis(); + if (PoolingSessionFactorySettings.HEALTH_CHECK_ENABLED.get(settings)) { + String entryDn = PoolingSessionFactorySettings.HEALTH_CHECK_DN.get(settings).orElseGet(healthCheckDnSupplier); + final long healthCheckInterval = PoolingSessionFactorySettings.HEALTH_CHECK_INTERVAL.get(settings).millis(); if (entryDn != null) { // Checks the status of the LDAP connection at a specified interval in the background. We do not check on // create as the LDAP server may require authentication to get an entry and a bind request has not been executed @@ -156,8 +135,9 @@ abstract class PoolingSessionFactory extends SessionFactory implements Releasabl pool.setHealthCheckIntervalMillis(healthCheckInterval); } else { logger.warn(new ParameterizedMessage("[{}] and [{}} have not been specified or are not valid distinguished names," + - "so connection health checking is disabled", RealmSettings.getFullSettingKey(config, BIND_DN), - RealmSettings.getFullSettingKey(config, HEALTH_CHECK_DN))); + "so connection health checking is disabled", RealmSettings.getFullSettingKey(config, + PoolingSessionFactorySettings.BIND_DN), + RealmSettings.getFullSettingKey(config, PoolingSessionFactorySettings.HEALTH_CHECK_DN))); } } @@ -189,8 +169,4 @@ abstract class PoolingSessionFactory extends SessionFactory implements Releasabl return connectionPool; } - 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/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java similarity index 76% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java index 054eb420466..37ef8d5d2a0 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolver.java @@ -14,7 +14,6 @@ import com.unboundid.ldap.sdk.SearchScope; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; @@ -22,18 +21,15 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession.GroupsRes import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; -import java.util.Set; -import java.util.function.Function; import static org.elasticsearch.common.Strings.isNullOrEmpty; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.OBJECT_CLASS_PRESENCE_FILTER; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.createFilter; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.search; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.searchForEntry; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.IGNORE_REFERRAL_ERRORS_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING; /** * Resolves the groups for a user by executing a search with a filter usually that contains a group @@ -41,21 +37,6 @@ import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory */ class SearchGroupsResolver implements GroupsResolver { - 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 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); - - static final Setting FILTER = new Setting<>("group_search.filter", - GROUP_SEARCH_DEFAULT_FILTER, Function.identity(), Setting.Property.NodeScope); - private final String baseDn; private final String filter; private final String userAttribute; @@ -63,14 +44,14 @@ class SearchGroupsResolver implements GroupsResolver { private final boolean ignoreReferralErrors; SearchGroupsResolver(Settings settings) { - if (BASE_DN.exists(settings)) { - baseDn = BASE_DN.get(settings); + if (SearchGroupsResolverSettings.BASE_DN.exists(settings)) { + baseDn = SearchGroupsResolverSettings.BASE_DN.get(settings); } else { throw new IllegalArgumentException("base_dn must be specified"); } - filter = FILTER.get(settings); - userAttribute = USER_ATTRIBUTE.get(settings); - scope = SCOPE.get(settings); + filter = SearchGroupsResolverSettings.FILTER.get(settings); + userAttribute = SearchGroupsResolverSettings.USER_ATTRIBUTE.get(settings); + scope = SearchGroupsResolverSettings.SCOPE.get(settings); this.ignoreReferralErrors = IGNORE_REFERRAL_ERRORS_SETTING.get(settings); } @@ -83,6 +64,7 @@ class SearchGroupsResolver implements GroupsResolver { } else { try { Filter userFilter = createFilter(filter, userId); + search(connection, baseDn, scope.scope(), userFilter, Math.toIntExact(timeout.seconds()), ignoreReferralErrors, ActionListener.wrap( @@ -138,12 +120,5 @@ class SearchGroupsResolver implements GroupsResolver { userAttribute); } - 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/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java similarity index 85% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java index c492a344f72..449fb3a46da 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolver.java @@ -10,7 +10,6 @@ import com.unboundid.ldap.sdk.LDAPInterface; import com.unboundid.ldap.sdk.SearchScope; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession.GroupsResolver; @@ -21,25 +20,21 @@ import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import java.util.Set; -import java.util.function.Function; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.OBJECT_CLASS_PRESENCE_FILTER; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.searchForEntry; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.IGNORE_REFERRAL_ERRORS_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING; /** * Resolves the groups of a user based on the value of a attribute of the user's ldap entry */ class UserAttributeGroupsResolver implements GroupsResolver { - private static final Setting ATTRIBUTE = new Setting<>("user_group_attribute", "memberOf", - Function.identity(), Setting.Property.NodeScope); private final String attribute; private final boolean ignoreReferralErrors; UserAttributeGroupsResolver(Settings settings) { - this(ATTRIBUTE.get(settings), IGNORE_REFERRAL_ERRORS_SETTING.get(settings)); + this(UserAttributeGroupsResolverSettings.ATTRIBUTE.get(settings), IGNORE_REFERRAL_ERRORS_SETTING.get(settings)); } private UserAttributeGroupsResolver(String attribute, boolean ignoreReferralErrors) { @@ -71,7 +66,5 @@ class UserAttributeGroupsResolver implements GroupsResolver { return new String[] { attribute }; } - public static Set> getSettings() { - return Collections.singleton(ATTRIBUTE); - } + } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java similarity index 79% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java index 40b206b0f66..1fa2ff4d095 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancing.java @@ -12,14 +12,11 @@ import com.unboundid.ldap.sdk.RoundRobinServerSet; import com.unboundid.ldap.sdk.ServerSet; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.network.InetAddresses; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import javax.net.SocketFactory; -import java.util.HashSet; import java.util.Locale; -import java.util.Set; /** * Enumeration representing the various supported {@link ServerSet} types that can be used with out built in realms. @@ -54,7 +51,7 @@ public enum LdapLoadBalancing { if (InetAddresses.isInetAddress(addresses[0])) { throw new IllegalArgumentException(toString() + " can only be used with a DNS name"); } - TimeValue dnsTtl = settings.getAsTime(CACHE_TTL_SETTING, CACHE_TTL_DEFAULT); + TimeValue dnsTtl = settings.getAsTime(LdapLoadBalancingSettings.CACHE_TTL_SETTING, CACHE_TTL_DEFAULT); return new RoundRobinDNSServerSet(addresses[0], ports[0], RoundRobinDNSServerSet.AddressSelectionMode.ROUND_ROBIN, dnsTtl.millis(), null, socketFactory, options); } @@ -70,16 +67,13 @@ public enum LdapLoadBalancing { if (InetAddresses.isInetAddress(addresses[0])) { throw new IllegalArgumentException(toString() + " can only be used with a DNS name"); } - TimeValue dnsTtl = settings.getAsTime(CACHE_TTL_SETTING, CACHE_TTL_DEFAULT); + TimeValue dnsTtl = settings.getAsTime(LdapLoadBalancingSettings.CACHE_TTL_SETTING, CACHE_TTL_DEFAULT); return new RoundRobinDNSServerSet(addresses[0], ports[0], RoundRobinDNSServerSet.AddressSelectionMode.FAILOVER, dnsTtl.millis(), null, socketFactory, options); } }; - public static final String LOAD_BALANCE_SETTINGS = "load_balance"; - public static final String LOAD_BALANCE_TYPE_SETTING = "type"; public static final String LOAD_BALANCE_TYPE_DEFAULT = LdapLoadBalancing.FAILOVER.toString(); - public static final String CACHE_TTL_SETTING = "cache_ttl"; public static final TimeValue CACHE_TTL_DEFAULT = TimeValue.timeValueHours(1L); abstract ServerSet buildServerSet(String[] addresses, int[] ports, Settings settings, @Nullable SocketFactory socketFactory, @@ -91,8 +85,8 @@ public enum LdapLoadBalancing { } public static LdapLoadBalancing resolve(Settings settings) { - Settings loadBalanceSettings = settings.getAsSettings(LOAD_BALANCE_SETTINGS); - String type = loadBalanceSettings.get(LOAD_BALANCE_TYPE_SETTING, LOAD_BALANCE_TYPE_DEFAULT); + Settings loadBalanceSettings = settings.getAsSettings(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS); + String type = loadBalanceSettings.get(LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, LOAD_BALANCE_TYPE_DEFAULT); try { return valueOf(type.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ilae) { @@ -103,14 +97,8 @@ public enum LdapLoadBalancing { public static ServerSet serverSet(String[] addresses, int[] ports, Settings settings, @Nullable SocketFactory socketFactory, @Nullable LDAPConnectionOptions options) { LdapLoadBalancing loadBalancing = resolve(settings); - Settings loadBalanceSettings = settings.getAsSettings(LOAD_BALANCE_SETTINGS); + Settings loadBalanceSettings = settings.getAsSettings(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS); return loadBalancing.buildServerSet(addresses, ports, loadBalanceSettings, socketFactory, options); } - 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/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java similarity index 88% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java index 8d2fde00ff2..4f6607d4064 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolver.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.security.authc.ldap.support; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; @@ -20,7 +19,6 @@ import com.unboundid.ldap.sdk.SearchResultEntry; import com.unboundid.ldap.sdk.SearchScope; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -29,14 +27,11 @@ import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.sear public class LdapMetaDataResolver { - public static final Setting> ADDITIONAL_META_DATA_SETTING = Setting.listSetting( - "metadata", Collections.emptyList(), Function.identity(), Setting.Property.NodeScope); - private final String[] attributeNames; private final boolean ignoreReferralErrors; public LdapMetaDataResolver(Settings settings, boolean ignoreReferralErrors) { - this(ADDITIONAL_META_DATA_SETTING.get(settings), ignoreReferralErrors); + this(LdapMetaDataResolverSettings.ADDITIONAL_META_DATA_SETTING.get(settings), ignoreReferralErrors); } LdapMetaDataResolver(Collection attributeNames, boolean ignoreReferralErrors) { @@ -87,7 +82,4 @@ public class LdapMetaDataResolver { ); } - 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/LdapSession.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSession.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSession.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapSession.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapUtils.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapUtils.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapUtils.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapUtils.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java similarity index 76% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java index a4f5a1860de..858a3b90ba6 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java @@ -12,11 +12,9 @@ import com.unboundid.ldap.sdk.ServerSet; import com.unboundid.util.ssl.HostNameSSLSocketVerifier; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.support.ThreadedActionListener; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; @@ -28,11 +26,7 @@ import org.elasticsearch.xpack.ssl.VerificationMode; import javax.net.SocketFactory; import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; -import java.util.function.Function; import java.util.regex.Pattern; /** @@ -50,16 +44,6 @@ import java.util.regex.Pattern; */ public abstract class SessionFactory { - 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 static final Pattern STARTS_WITH_LDAPS = Pattern.compile("^ldaps:.*", Pattern.CASE_INSENSITIVE); private static final Pattern STARTS_WITH_LDAP = Pattern.compile("^ldap:.*", @@ -79,7 +63,7 @@ public abstract class SessionFactory { this.config = config; this.logger = config.logger(getClass()); final Settings settings = config.settings(); - TimeValue searchTimeout = settings.getAsTime(TIMEOUT_LDAP_SETTING, TIMEOUT_DEFAULT); + TimeValue searchTimeout = settings.getAsTime(SessionFactorySettings.TIMEOUT_LDAP_SETTING, SessionFactorySettings.TIMEOUT_DEFAULT); if (searchTimeout.millis() < 1000L) { logger.warn("ldap_search timeout [{}] is less than the minimum supported search " + "timeout of 1s. using 1s", @@ -92,7 +76,7 @@ public abstract class SessionFactory { LDAPServers ldapServers = ldapServers(settings); this.serverSet = serverSet(config, sslService, ldapServers); this.sslUsed = ldapServers.ssl; - this.ignoreReferralErrors = IGNORE_REFERRAL_ERRORS_SETTING.get(settings); + this.ignoreReferralErrors = SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING.get(settings); } /** @@ -133,11 +117,12 @@ public abstract class SessionFactory { Settings realmSettings = config.settings(); LDAPConnectionOptions options = new LDAPConnectionOptions(); options.setConnectTimeoutMillis(Math.toIntExact( - realmSettings.getAsTime(TIMEOUT_TCP_CONNECTION_SETTING, TIMEOUT_DEFAULT).millis() + realmSettings.getAsTime(SessionFactorySettings.TIMEOUT_TCP_CONNECTION_SETTING, + SessionFactorySettings.TIMEOUT_DEFAULT).millis() )); - options.setFollowReferrals(realmSettings.getAsBoolean(FOLLOW_REFERRALS_SETTING, true)); + options.setFollowReferrals(realmSettings.getAsBoolean(SessionFactorySettings.FOLLOW_REFERRALS_SETTING, true)); options.setResponseTimeoutMillis( - realmSettings.getAsTime(TIMEOUT_TCP_READ_SETTING, TIMEOUT_DEFAULT).millis() + realmSettings.getAsTime(SessionFactorySettings.TIMEOUT_TCP_READ_SETTING, SessionFactorySettings.TIMEOUT_DEFAULT).millis() ); options.setAllowConcurrentSocketFactoryUse(true); @@ -147,10 +132,10 @@ public abstract class SessionFactory { final boolean verificationModeExists = sslConfigurationSettings.verificationMode.exists(realmSSLSettings); final boolean hostnameVerficationExists = - realmSettings.get(HOSTNAME_VERIFICATION_SETTING, null) != null; + realmSettings.get(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, null) != null; if (verificationModeExists && hostnameVerficationExists) { - throw new IllegalArgumentException("[" + HOSTNAME_VERIFICATION_SETTING + "] and [" + + throw new IllegalArgumentException("[" + SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING + "] and [" + sslConfigurationSettings.verificationMode.getKey() + "] may not be used at the same time"); } else if (verificationModeExists) { @@ -162,10 +147,10 @@ public abstract class SessionFactory { } else if (hostnameVerficationExists) { new DeprecationLogger(logger).deprecated("the setting [{}] has been deprecated and " + "will be removed in a future version. use [{}] instead", - RealmSettings.getFullSettingKey(config, HOSTNAME_VERIFICATION_SETTING), + RealmSettings.getFullSettingKey(config, SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING), RealmSettings.getFullSettingKey(config, "ssl." + sslConfigurationSettings.verificationMode.getKey())); - if (realmSettings.getAsBoolean(HOSTNAME_VERIFICATION_SETTING, true)) { + if (realmSettings.getAsBoolean(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, true)) { options.setSSLSocketVerifier(new HostNameSSLSocketVerifier(true)); } } else { @@ -176,9 +161,9 @@ public abstract class SessionFactory { private LDAPServers ldapServers(Settings settings) { // Parse LDAP urls - List ldapUrls = settings.getAsList(URLS_SETTING, getDefaultLdapUrls(settings)); + List ldapUrls = settings.getAsList(SessionFactorySettings.URLS_SETTING, getDefaultLdapUrls(settings)); if (ldapUrls == null || ldapUrls.isEmpty()) { - throw new IllegalArgumentException("missing required LDAP setting [" + URLS_SETTING + + throw new IllegalArgumentException("missing required LDAP setting [" + SessionFactorySettings.URLS_SETTING + "]"); } return new LDAPServers(ldapUrls.toArray(new String[ldapUrls.size()])); @@ -194,7 +179,7 @@ public abstract class SessionFactory { SocketFactory socketFactory = null; if (ldapServers.ssl()) { socketFactory = clientSSLService.sslSocketFactory(settings.getByPrefix("ssl.")); - if (settings.getAsBoolean(HOSTNAME_VERIFICATION_SETTING, true)) { + if (settings.getAsBoolean(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, true)) { logger.debug("using encryption for LDAP connections with hostname verification"); } else { logger.debug("using encryption for LDAP connections without hostname verification"); @@ -213,21 +198,6 @@ public abstract class SessionFactory { return sslUsed; } - protected static Set> getSettings() { - Set> settings = new HashSet<>(); - settings.addAll(LdapLoadBalancing.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; - } - public static class LDAPServers { private final String[] addresses; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java similarity index 79% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java index 4bfa884b3a2..985a82340b9 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java @@ -12,7 +12,6 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.Environment; @@ -33,24 +32,15 @@ import javax.net.ssl.X509TrustManager; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PkiRealm extends Realm { public static final String PKI_CERT_HEADER_NAME = "__SECURITY_CLIENT_CERTIFICATE"; - public static final String TYPE = "pki"; - - static final String DEFAULT_USERNAME_PATTERN = "CN=(.*?)(?:,|$)"; - private static final Setting USERNAME_PATTERN_SETTING = new Setting<>("username_pattern", DEFAULT_USERNAME_PATTERN, - s -> Pattern.compile(s, Pattern.CASE_INSENSITIVE), Setting.Property.NodeScope); - private static final SSLConfigurationSettings SSL_SETTINGS = SSLConfigurationSettings.withoutPrefix(); // For client based cert validation, the auth type must be specified but UNKNOWN is an acceptable value private static final String AUTH_TYPE = "UNKNOWN"; @@ -61,14 +51,14 @@ public class PkiRealm extends Realm { public PkiRealm(RealmConfig config, ResourceWatcherService watcherService, NativeRoleMappingStore nativeRoleMappingStore) { - this(config, new CompositeRoleMapper(TYPE, config, watcherService, nativeRoleMappingStore)); + this(config, new CompositeRoleMapper(PkiRealmSettings.TYPE, config, watcherService, nativeRoleMappingStore)); } // pkg private for testing PkiRealm(RealmConfig config, UserRoleMapper roleMapper) { - super(TYPE, config); + super(PkiRealmSettings.TYPE, config); this.trustManager = trustManagers(config); - this.principalPattern = USERNAME_PATTERN_SETTING.get(config.settings()); + this.principalPattern = PkiRealmSettings.USERNAME_PATTERN_SETTING.get(config.settings()); this.roleMapper = roleMapper; } @@ -158,13 +148,13 @@ public class PkiRealm extends Realm { static X509TrustManager trustManagers(RealmConfig realmConfig) { final Settings settings = realmConfig.settings(); final Environment env = realmConfig.env(); - List certificateAuthorities = settings.getAsList(SSL_SETTINGS.caPaths.getKey(), null); - String truststorePath = SSL_SETTINGS.truststorePath.get(settings).orElse(null); + List certificateAuthorities = settings.getAsList(PkiRealmSettings.SSL_SETTINGS.caPaths.getKey(), null); + String truststorePath = PkiRealmSettings.SSL_SETTINGS.truststorePath.get(settings).orElse(null); if (truststorePath == null && certificateAuthorities == null) { return null; } else if (truststorePath != null && certificateAuthorities != null) { - final String pathKey = RealmSettings.getFullSettingKey(realmConfig, SSL_SETTINGS.truststorePath); - final String caKey = RealmSettings.getFullSettingKey(realmConfig, SSL_SETTINGS.caPaths); + final String pathKey = RealmSettings.getFullSettingKey(realmConfig, PkiRealmSettings.SSL_SETTINGS.truststorePath); + final String caKey = RealmSettings.getFullSettingKey(realmConfig, PkiRealmSettings.SSL_SETTINGS.caPaths); throw new IllegalArgumentException("[" + pathKey + "] and [" + caKey + "] cannot be used at the same time"); } else if (truststorePath != null) { return trustManagersFromTruststore(truststorePath, realmConfig); @@ -174,15 +164,17 @@ public class PkiRealm extends Realm { private static X509TrustManager trustManagersFromTruststore(String truststorePath, RealmConfig realmConfig) { final Settings settings = realmConfig.settings(); - if (SSL_SETTINGS.truststorePassword.exists(settings) == false && SSL_SETTINGS.legacyTruststorePassword.exists(settings) == false) { + if (PkiRealmSettings.SSL_SETTINGS.truststorePassword.exists(settings) == false + && PkiRealmSettings.SSL_SETTINGS.legacyTruststorePassword.exists(settings) == false) { throw new IllegalArgumentException("Neither [" + - RealmSettings.getFullSettingKey(realmConfig, SSL_SETTINGS.truststorePassword) + "] or [" + - RealmSettings.getFullSettingKey(realmConfig, SSL_SETTINGS.legacyTruststorePassword) + "] is configured" + RealmSettings.getFullSettingKey(realmConfig, PkiRealmSettings.SSL_SETTINGS.truststorePassword) + "] or [" + + RealmSettings.getFullSettingKey(realmConfig, PkiRealmSettings.SSL_SETTINGS.legacyTruststorePassword) + "] is configured" ); } - try (SecureString password = SSL_SETTINGS.truststorePassword.get(settings)) { - String trustStoreAlgorithm = SSL_SETTINGS.truststoreAlgorithm.get(settings); - String trustStoreType = SSLConfigurationSettings.getKeyStoreType(SSL_SETTINGS.truststoreType, settings, truststorePath); + try (SecureString password = PkiRealmSettings.SSL_SETTINGS.truststorePassword.get(settings)) { + String trustStoreAlgorithm = PkiRealmSettings.SSL_SETTINGS.truststoreAlgorithm.get(settings); + String trustStoreType = SSLConfigurationSettings.getKeyStoreType(PkiRealmSettings.SSL_SETTINGS.truststoreType, + settings, truststorePath); try { return CertUtils.trustManager(truststorePath, trustStoreType, password.getChars(), trustStoreAlgorithm, realmConfig.env()); } catch (Exception e) { @@ -192,7 +184,7 @@ public class PkiRealm extends Realm { } private static X509TrustManager trustManagersFromCAs(Settings settings, Environment env) { - List certificateAuthorities = settings.getAsList(SSL_SETTINGS.caPaths.getKey(), null); + List certificateAuthorities = settings.getAsList(PkiRealmSettings.SSL_SETTINGS.caPaths.getKey(), null); assert certificateAuthorities != null; try { Certificate[] certificates = CertUtils.readCertificates(certificateAuthorities, env); @@ -202,21 +194,4 @@ public class PkiRealm extends Realm { } } - /** - * @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(CompositeRoleMapper.getSettings()); - - return settings; - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/pki/X509AuthenticationToken.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/X509AuthenticationToken.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/pki/X509AuthenticationToken.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/X509AuthenticationToken.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingRealm.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingRealm.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java similarity index 88% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java index 5dfca82779a..9fd46891fbb 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealm.java @@ -5,18 +5,14 @@ */ package org.elasticsearch.xpack.security.authc.support; -import java.util.Arrays; -import java.util.HashSet; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.concurrent.ExecutionException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.cache.Cache; import org.elasticsearch.common.cache.CacheBuilder; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.AuthenticationToken; @@ -25,26 +21,17 @@ import org.elasticsearch.xpack.security.user.User; public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm implements CachingRealm { - 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 final Cache cache; final Hasher hasher; protected CachingUsernamePasswordRealm(String type, RealmConfig config) { super(type, config); - hasher = Hasher.resolve(CACHE_HASH_ALGO_SETTING.get(config.settings()), Hasher.SSHA256); - TimeValue ttl = CACHE_TTL_SETTING.get(config.settings()); + hasher = Hasher.resolve(CachingUsernamePasswordRealmSettings.CACHE_HASH_ALGO_SETTING.get(config.settings()), Hasher.SSHA256); + TimeValue ttl = CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.get(config.settings()); if (ttl.getNanos() > 0) { cache = CacheBuilder.builder() .setExpireAfterWrite(ttl) - .setMaximumWeight(CACHE_MAX_USERS_SETTING.get(config.settings())) + .setMaximumWeight(CachingUsernamePasswordRealmSettings.CACHE_MAX_USERS_SETTING.get(config.settings())) .build(); } else { cache = null; @@ -201,13 +188,6 @@ public abstract class CachingUsernamePasswordRealm extends UsernamePasswordRealm protected abstract void doLookupUser(String username, ActionListener listener); - /** - * Returns the {@link Setting setting configuration} that is common for all caching realms - */ - protected static Set> getCachingSettings() { - return new HashSet<>(Arrays.asList(CACHE_HASH_ALGO_SETTING, CACHE_TTL_SETTING, CACHE_MAX_USERS_SETTING)); - } - private static class UserWithHash { User user; char[] hash; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java similarity index 91% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java index 6e6b07686fb..f13de374e6c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapper.java @@ -8,17 +8,14 @@ package org.elasticsearch.xpack.security.authc.support; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.function.Function; import com.unboundid.ldap.sdk.DN; import com.unboundid.ldap.sdk.LDAPException; @@ -27,7 +24,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.util.Supplier; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.env.Environment; @@ -47,13 +43,6 @@ import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.rela */ public class DnRoleMapper implements UserRoleMapper { - 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); - protected final Logger logger; protected final RealmConfig config; @@ -66,7 +55,7 @@ public class DnRoleMapper implements UserRoleMapper { this.config = config; this.logger = config.logger(getClass()); - useUnmappedGroupsAsRoles = USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.get(config.settings()); + useUnmappedGroupsAsRoles = DnRoleMapperSettings.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.get(config.settings()); file = resolveFile(config.settings(), config.env()); dnRoles = parseFileLenient(file, logger, config.type(), config.name()); FileWatcher watcher = new FileWatcher(file.getParent()); @@ -88,7 +77,7 @@ public class DnRoleMapper implements UserRoleMapper { } public static Path resolveFile(Settings settings, Environment env) { - String location = ROLE_MAPPING_FILE_SETTING.get(settings); + String location = DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.get(settings); return XPackPlugin.resolveConfigFile(env, location); } @@ -214,10 +203,6 @@ public class DnRoleMapper implements UserRoleMapper { listeners.forEach(Runnable::run); } - public static List> getSettings() { - return Arrays.asList(USE_UNMAPPED_GROUPS_AS_ROLES_SETTING, ROLE_MAPPING_FILE_SETTING); - } - private class FileListener implements FileChangesListener { @Override public void onFileCreated(Path file) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java similarity index 91% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java index b948920ddcc..afb23ccb187 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheck.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security.authc.support; import java.nio.file.Path; -import org.apache.lucene.util.SetOnce; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.bootstrap.BootstrapContext; import org.elasticsearch.xpack.security.authc.RealmConfig; @@ -42,7 +41,7 @@ public class RoleMappingFileBootstrapCheck implements BootstrapCheck { } public static BootstrapCheck create(RealmConfig realmConfig) { - if (realmConfig.enabled() && DnRoleMapper.ROLE_MAPPING_FILE_SETTING.exists(realmConfig.settings())) { + if (realmConfig.enabled() && DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.exists(realmConfig.settings())) { Path file = DnRoleMapper.resolveFile(realmConfig.settings(), realmConfig.env()); return new RoleMappingFileBootstrapCheck(realmConfig, file); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UserRoleMapper.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/UserRoleMapper.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UserRoleMapper.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/UserRoleMapper.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordRealm.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordRealm.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordRealm.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordRealm.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java similarity index 95% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java index e981456ac6b..f641fa1b12b 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/CompositeRoleMapper.java @@ -54,7 +54,4 @@ public class CompositeRoleMapper implements UserRoleMapper { this.delegates.forEach(mapper -> mapper.refreshRealmOnChange(realm)); } - public static Collection> getSettings() { - return DnRoleMapper.getSettings(); - } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java index 3ed1d615b3e..95fb684cbb8 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java @@ -56,7 +56,7 @@ import org.elasticsearch.xpack.security.action.user.UserRequest; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.elasticsearch.xpack.security.authc.Authentication; import org.elasticsearch.xpack.security.authc.AuthenticationFailureHandler; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; import org.elasticsearch.xpack.security.authz.IndicesAndAliasesResolver.ResolvedIndices; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; @@ -65,7 +65,6 @@ import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsCache; import org.elasticsearch.xpack.security.authz.permission.Role; import org.elasticsearch.xpack.security.authz.privilege.ClusterPrivilege; import org.elasticsearch.xpack.security.authz.privilege.IndexPrivilege; -import org.elasticsearch.xpack.security.authz.store.ClientReservedRoles; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore; import org.elasticsearch.xpack.security.support.Automatons; @@ -82,7 +81,6 @@ public class AuthorizationService extends AbstractComponent { public static final Setting ANONYMOUS_AUTHORIZATION_EXCEPTION_SETTING = Setting.boolSetting(setting("authc.anonymous.authz_exception"), true, Property.NodeScope); - public static final String INDICES_PERMISSIONS_KEY = "_indices_permissions"; public static final String ORIGINATING_ACTION_KEY = "_originating_action_name"; public static final String ROLE_NAMES_KEY = "_effective_role_names"; @@ -151,7 +149,7 @@ public class AuthorizationService extends AbstractComponent { // first we need to check if the user is the system. If it is, we'll just authorize the system access if (SystemUser.is(authentication.getUser())) { if (SystemUser.isAuthorized(action)) { - putTransientIfNonExisting(INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_ALL); + putTransientIfNonExisting(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_ALL); putTransientIfNonExisting(ROLE_NAMES_KEY, new String[] { SystemUser.ROLE_NAME }); grant(authentication, action, request, new String[] { SystemUser.ROLE_NAME }); return; @@ -182,7 +180,7 @@ public class AuthorizationService extends AbstractComponent { if (ClusterPrivilege.ACTION_MATCHER.test(action)) { ClusterPermission cluster = permission.cluster(); if (cluster.check(action) || checkSameUserPermissions(action, request, authentication)) { - putTransientIfNonExisting(INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_ALL); + putTransientIfNonExisting(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_ALL); grant(authentication, action, request, permission.names()); return; } @@ -287,7 +285,7 @@ public class AuthorizationService extends AbstractComponent { //all wildcard expressions have been resolved and only the security plugin could have set '-*' here. //'-*' matches no indices so we allow the request to go through, which will yield an empty response if (resolvedIndices.isNoIndicesPlaceholder()) { - putTransientIfNonExisting(INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_NO_INDICES); + putTransientIfNonExisting(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, IndicesAccessControl.ALLOW_NO_INDICES); grant(authentication, action, request, permission.names()); return; } @@ -305,7 +303,7 @@ public class AuthorizationService extends AbstractComponent { authentication.getUser().principal(), action, SecurityLifecycleService.SECURITY_INDEX_NAME); throw denial(authentication, action, request, permission.names()); } else { - putTransientIfNonExisting(INDICES_PERMISSIONS_KEY, indicesAccessControl); + putTransientIfNonExisting(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, indicesAccessControl); } //if we are creating an index we need to authorize potential aliases created at the same time @@ -464,7 +462,7 @@ public class AuthorizationService extends AbstractComponent { if (roleNames.isEmpty()) { roleActionListener.onResponse(Role.EMPTY); - } else if (roleNames.contains(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName())) { + } else if (roleNames.contains(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName())) { roleActionListener.onResponse(ReservedRolesStore.SUPERUSER_ROLE); } else { rolesStore.roles(roleNames, fieldPermissionsCache, roleActionListener); @@ -542,7 +540,7 @@ public class AuthorizationService extends AbstractComponent { assert realmType != null; // ensure the user was authenticated by a realm that we can change a password for. The native realm is an internal realm and // right now only one can exist in the realm configuration - if this changes we should update this check - return ReservedRealm.TYPE.equals(realmType) || NativeRealm.TYPE.equals(realmType); + return ReservedRealm.TYPE.equals(realmType) || NativeRealmSettings.TYPE.equals(realmType); } ElasticsearchSecurityException denial(Authentication authentication, String action, TransportRequest request, String[] roleNames) { @@ -582,7 +580,7 @@ public class AuthorizationService extends AbstractComponent { static boolean isSuperuser(User user) { return Arrays.stream(user.roles()) - .anyMatch(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName()::equals); + .anyMatch(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName()::equals); } public static void addSettings(List> settings) { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationUtils.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizedIndices.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizedIndices.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizedIndices.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizedIndices.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java index 9bba9dfa503..fc1b0c4688d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java @@ -41,9 +41,8 @@ import org.elasticsearch.xpack.graph.action.GraphExploreRequest; public class IndicesAndAliasesResolver { - //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 static final ResolvedIndices NO_INDEX_PLACEHOLDER_RESOLVED = ResolvedIndices.local(NO_INDEX_PLACEHOLDER); + private static final ResolvedIndices NO_INDEX_PLACEHOLDER_RESOLVED = + ResolvedIndices.local(IndicesAndAliasesResolverField.NO_INDEX_PLACEHOLDER); //`*,-*` what we replace indices with if we need Elasticsearch to return empty responses without throwing exception private static final String[] NO_INDICES_ARRAY = new String[] { "*", "-*" }; static final List NO_INDICES_LIST = Arrays.asList(NO_INDICES_ARRAY); @@ -468,10 +467,10 @@ public class IndicesAndAliasesResolver { /** * @return true if the {@link #getRemote() remote} index lists is empty, and the local index list contains the - * {@link IndicesAndAliasesResolver#NO_INDEX_PLACEHOLDER no-index-placeholder} and nothing else. + * {@link IndicesAndAliasesResolverField#NO_INDEX_PLACEHOLDER no-index-placeholder} and nothing else. */ public boolean isNoIndicesPlaceholder() { - return remote.isEmpty() && local.size() == 1 && local.contains(IndicesAndAliasesResolver.NO_INDEX_PLACEHOLDER); + return remote.isEmpty() && local.size() == 1 && local.contains(IndicesAndAliasesResolverField.NO_INDEX_PLACEHOLDER); } private String[] toArray() { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListener.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListener.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListener.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListener.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java index 56d7a304ace..6e05320e20b 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapper.java @@ -59,6 +59,7 @@ import org.elasticsearch.script.ScriptType; import org.elasticsearch.script.TemplateScript; import org.elasticsearch.xpack.security.authc.Authentication; import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.DocumentSubsetReader.DocumentSubsetDirectoryReader; import org.elasticsearch.xpack.security.support.Exceptions; import org.elasticsearch.xpack.security.user.User; @@ -289,7 +290,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper { } protected IndicesAccessControl getIndicesAccessControl() { - IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationService.INDICES_PERMISSIONS_KEY); + IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY); if (indicesAccessControl == null) { throw Exceptions.authorizationError("no indices permissions found"); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java index 23b912fb278..24f83ca65d1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java @@ -16,7 +16,7 @@ import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.env.Environment; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; @@ -68,7 +68,7 @@ public class SystemKeyTool extends EnvironmentAwareCommand { } keyPath = parsePath(args.get(0)); } else { - keyPath = env.configFile().resolve(XpackField.NAME).resolve("system_key"); + keyPath = env.configFile().resolve(XPackField.NAME).resolve("system_key"); } // write the key diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/RemoteHostHeader.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/RemoteHostHeader.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/RemoteHostHeader.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/RemoteHostHeader.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/SecurityRestFilter.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/SecurityRestFilter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/SecurityRestFilter.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/SecurityRestFilter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java index 4a4d8772c09..711d512549c 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandler.java @@ -15,7 +15,7 @@ import org.elasticsearch.rest.RestRequest; import java.io.IOException; -import static org.elasticsearch.xpack.XpackField.SECURITY; +import static org.elasticsearch.xpack.XPackField.SECURITY; /** * Base class for security rest handlers. This handler takes care of ensuring that the license diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestInvalidateTokenAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestInvalidateTokenAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestInvalidateTokenAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestInvalidateTokenAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/realm/RestClearRealmCacheAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/realm/RestClearRealmCacheAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/realm/RestClearRealmCacheAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/realm/RestClearRealmCacheAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestClearRolesCacheAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestClearRolesCacheAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestClearRolesCacheAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestClearRolesCacheAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestDeleteRoleAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestDeleteRoleAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestDeleteRoleAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestDeleteRoleAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestGetRolesAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/role/RestPutRoleAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestDeleteRoleMappingAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestDeleteRoleMappingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestDeleteRoleMappingAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestDeleteRoleMappingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestGetRoleMappingsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/rolemapping/RestPutRoleMappingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestDeleteUserAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestDeleteUserAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestDeleteUserAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestDeleteUserAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestGetUsersAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestHasPrivilegesAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestPutUserAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/support/AbstractSecurityModule.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/AbstractSecurityModule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/support/AbstractSecurityModule.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/support/AbstractSecurityModule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/support/FileAttributesChecker.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/FileAttributesChecker.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/support/FileAttributesChecker.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/support/FileAttributesChecker.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java similarity index 99% rename from plugin/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java index 881edb267ed..0ae07d85281 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/IndexLifecycleManager.java @@ -35,7 +35,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.xpack.template.TemplateUtils; -import org.elasticsearch.xpack.upgrade.IndexUpgradeCheck; +import org.elasticsearch.xpack.upgrade.IndexUpgradeCheckVersion; import java.nio.charset.StandardCharsets; import java.util.HashSet; @@ -53,14 +53,14 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_FORMAT_SETT import static org.elasticsearch.xpack.ClientHelper.SECURITY_ORIGIN; import static org.elasticsearch.xpack.ClientHelper.executeAsyncWithOrigin; import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_INDEX_NAME; -import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.security.SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME; /** * Manages the lifecycle of a single index, its template, mapping and and data upgrades/migrations. */ public class IndexLifecycleManager extends AbstractComponent { - public static final String INTERNAL_SECURITY_INDEX = ".security-" + IndexUpgradeCheck.UPRADE_VERSION; + public static final String INTERNAL_SECURITY_INDEX = ".security-" + IndexUpgradeCheckVersion.UPRADE_VERSION; public static final int INTERNAL_INDEX_FORMAT = 6; public static final String SECURITY_VERSION_STRING = "security-version"; public static final String TEMPLATE_VERSION_PATTERN = diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/support/SecurityFiles.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityFiles.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/support/SecurityFiles.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityFiles.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/PatternRule.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/PatternRule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/PatternRule.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/PatternRule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRule.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRule.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilter.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilter.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilter.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilter.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java similarity index 94% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java index 56848453b0c..858ccc0e954 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransport.java @@ -53,7 +53,7 @@ public class SecurityNetty4ServerTransport extends SecurityNetty4Transport { return new SecurityServerChannelInitializer(name, configuration); } - class IPFilterServerChannelInitializer extends ServerChannelInitializer { + public class IPFilterServerChannelInitializer extends ServerChannelInitializer { IPFilterServerChannelInitializer(final String name) { super(name); @@ -66,7 +66,7 @@ public class SecurityNetty4ServerTransport extends SecurityNetty4Transport { } } - class SecurityServerChannelInitializer extends SslChannelInitializer { + public class SecurityServerChannelInitializer extends SslChannelInitializer { SecurityServerChannelInitializer(final String name, final SSLConfiguration configuration) { super(name, configuration); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLChannelContext.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLChannelContext.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLChannelContext.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLChannelContext.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLDriver.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLDriver.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLDriver.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SSLDriver.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java rename to plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java diff --git a/plugin/security/src/main/plugin-metadata/plugin-security.policy b/plugin/security/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/security/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java b/plugin/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/integration/AbstractPrivilegeTestCase.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index ea7b156355f..6fe40554794 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; @@ -75,7 +76,7 @@ public class BulkUpdateTests extends SecurityIntegTestCase { final String path = "/index1/type/1"; final Header basicAuthHeader = new BasicHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray()))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); StringEntity body = new StringEntity("{\"test\":\"test\"}", ContentType.APPLICATION_JSON); Response response = getRestClient().performRequest("PUT", path, Collections.emptyMap(), body, basicAuthHeader); diff --git a/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java index 42af765dd15..85e972170a0 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/ClearRealmsCacheTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.action.realm.ClearRealmCacheRequest; import org.elasticsearch.xpack.security.action.realm.ClearRealmCacheResponse; import org.elasticsearch.xpack.security.authc.AuthenticationResult; @@ -166,7 +167,7 @@ public class ClearRealmsCacheTests extends SecurityIntegTestCase { Response response = getRestClient().performRequest("POST", path, params, new BasicHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())))); assertNotNull(response.getEntity()); assertTrue(EntityUtils.toString(response.getEntity()).contains("cluster_name")); } diff --git a/plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityRandomTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityRandomTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityRandomTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityRandomTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index b4dff6e6de7..40b1f333f3e 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -53,8 +53,9 @@ import org.elasticsearch.search.suggest.term.TermSuggestion; import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; import org.elasticsearch.test.InternalSettingsPlugin; import org.elasticsearch.test.SecurityIntegTestCase; -import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.authc.support.Hasher; import java.util.Arrays; @@ -88,7 +89,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase { @Override protected Collection> nodePlugins() { - return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, ParentJoinPlugin.class, InternalSettingsPlugin.class); + return Arrays.asList(LocalStateSecurity.class, CommonAnalysisPlugin.class, ParentJoinPlugin.class, InternalSettingsPlugin.class); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityRandomTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index 3ac523a5860..4a26f50b158 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -38,8 +38,9 @@ import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalSettingsPlugin; import org.elasticsearch.test.SecurityIntegTestCase; -import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.authc.support.Hasher; import java.util.Arrays; @@ -73,7 +74,7 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase { @Override protected Collection> nodePlugins() { - return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, ParentJoinPlugin.class, + return Arrays.asList(LocalStateSecurity.class, CommonAnalysisPlugin.class, ParentJoinPlugin.class, InternalSettingsPlugin.class); } diff --git a/plugin/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/MultipleIndicesPermissionsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/PermissionPrecedenceTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/PermissionPrecedenceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/PermissionPrecedenceTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/PermissionPrecedenceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java index 487d57e2318..9794e757700 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/SecurityCachePermissionTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.indices.TermsLookup; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.junit.Before; import static java.util.Collections.singletonMap; @@ -60,7 +61,7 @@ public class SecurityCachePermissionTests extends SecurityIntegTestCase { // Repeat with unauthorized user!!!! try { response = client().filterWithHeader(singletonMap("Authorization", basicAuthHeaderValue(READ_ONE_IDX_USER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))) + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))) .prepareSearch("data").setTypes("a").setQuery(QueryBuilders.constantScoreQuery( QueryBuilders.termsLookupQuery("token", new TermsLookup("tokens", "tokens", "1", "tokens")))) .execute().actionGet(); diff --git a/plugin/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java index 44351d710cb..ce6cd130e2d 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/SecurityClearScrollTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.authc.support.Hasher; import org.elasticsearch.test.SecurityIntegTestCase; import org.junit.After; @@ -92,7 +93,7 @@ public class SecurityClearScrollTests extends SecurityIntegTestCase { String user = "allowed_user:change_me"; String basicAuth = basicAuthHeaderValue("allowed_user", new SecureString("change_me".toCharArray())); Map headers = new HashMap<>(); - headers.put(Security.USER_SETTING.getKey(), user); + headers.put(SecurityField.USER_SETTING.getKey(), user); headers.put(BASIC_AUTH_HEADER, basicAuth); ClearScrollResponse clearScrollResponse = internalCluster().transportClient().filterWithHeader(headers) .prepareClearScroll() @@ -106,7 +107,7 @@ public class SecurityClearScrollTests extends SecurityIntegTestCase { String user = "denied_user:change_me"; String basicAuth = basicAuthHeaderValue("denied_user", new SecureString("change_me".toCharArray())); Map headers = new HashMap<>(); - headers.put(Security.USER_SETTING.getKey(), user); + headers.put(SecurityField.USER_SETTING.getKey(), user); headers.put(BASIC_AUTH_HEADER, basicAuth); assertThrows(internalCluster().transportClient().filterWithHeader(headers) .prepareClearScroll() diff --git a/plugin/src/test/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java index 995ce8e7f34..e84d82525a3 100644 --- a/plugin/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java +++ b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/AbstractAdLdapRealmTestCase.java @@ -6,8 +6,8 @@ package org.elasticsearch.integration.ldap; import org.elasticsearch.ElasticsearchSecurityException; -import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.ActionFuture; +import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.Client; @@ -22,10 +22,10 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; -import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.elasticsearch.xpack.security.action.rolemapping.PutRoleMappingRequestBuilder; import org.elasticsearch.xpack.security.action.rolemapping.PutRoleMappingResponse; -import org.elasticsearch.xpack.security.authc.ldap.LdapRealm; +import org.elasticsearch.xpack.security.authc.ldap.LdapRealmSettings; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.client.SecurityClient; import org.junit.After; @@ -197,7 +197,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase @Override public Set excludeTemplates() { Set templates = Sets.newHashSet(super.excludeTemplates()); - templates.add(SecurityLifecycleService.SECURITY_TEMPLATE_NAME); // don't remove the security index template + templates.add(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME); // don't remove the security index template return templates; } @@ -375,7 +375,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase AD(false, AD_ROLE_MAPPING, Settings.builder() - .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.AD_TYPE) + .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealmSettings.AD_TYPE) .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".domain_name", "ad.test.elasticsearch.com") .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn", "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com") @@ -384,7 +384,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase AD_SSL(false, AD_ROLE_MAPPING, Settings.builder() - .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.AD_TYPE) + .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealmSettings.AD_TYPE) .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".domain_name", "ad.test.elasticsearch.com") .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn", "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com") @@ -394,7 +394,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase AD_LDAP_GROUPS_FROM_SEARCH(true, AD_ROLE_MAPPING, Settings.builder() - .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.LDAP_TYPE) + .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealmSettings.LDAP_TYPE) .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".url", "ldaps://ad.test.elasticsearch.com:636") .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn", "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com") @@ -405,7 +405,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase AD_LDAP_GROUPS_FROM_ATTRIBUTE(true, AD_ROLE_MAPPING, Settings.builder() - .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.LDAP_TYPE) + .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".type", LdapRealmSettings.LDAP_TYPE) .put(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".url", "ldaps://ad.test.elasticsearch.com:636") .putList(XPACK_SECURITY_AUTHC_REALMS_EXTERNAL + ".user_dn_templates", "cn={0},CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com") diff --git a/plugin/src/test/java/org/elasticsearch/integration/ldap/ActiveDirectoryRunAsTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/ActiveDirectoryRunAsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ldap/ActiveDirectoryRunAsTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ldap/ActiveDirectoryRunAsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/ldap/GroupMappingTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/GroupMappingTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ldap/GroupMappingTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ldap/GroupMappingTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/ldap/MultiGroupMappingTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/MultiGroupMappingTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ldap/MultiGroupMappingTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ldap/MultiGroupMappingTests.java diff --git a/plugin/src/test/java/org/elasticsearch/integration/ldap/MultipleAdRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/integration/ldap/MultipleAdRealmTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/integration/ldap/MultipleAdRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/integration/ldap/MultipleAdRealmTests.java diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceSingleNodeSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/license/LicenseServiceSingleNodeSecurityTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/license/LicenseServiceSingleNodeSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/license/LicenseServiceSingleNodeSecurityTests.java diff --git a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java similarity index 91% rename from plugin/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java index 4b7895cda52..230e29c6b80 100644 --- a/plugin/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/license/LicenseServiceWithSecurityTests.java @@ -10,7 +10,8 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.transport.Netty4Plugin; -import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import java.util.Arrays; import java.util.Collection; @@ -24,7 +25,7 @@ public class LicenseServiceWithSecurityTests extends SecurityIntegTestCase { @Override protected Collection> nodePlugins() { - return Arrays.asList(XPackPlugin.class, CommonAnalysisPlugin.class, Netty4Plugin.class); + return Arrays.asList(LocalStateSecurity.class, CommonAnalysisPlugin.class, Netty4Plugin.class); } @Override diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java b/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/license/LicensingTests.java rename to plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java index d4987db28f7..c9c6893ae39 100644 --- a/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java @@ -28,12 +28,14 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.action.user.GetUsersResponse; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.client.SecurityClient; @@ -185,22 +187,24 @@ public class LicensingTests extends SecurityIntegTestCase { enableLicensing(mode); e = expectThrows(ResponseException.class, () -> getRestClient().performRequest("GET", "/")); assertThat(e.getResponse().getStatusLine().getStatusCode(), is(401)); - e = expectThrows(ResponseException.class, () -> getRestClient().performRequest("GET", "/_xpack/security/_authenticate")); + e = expectThrows(ResponseException.class, + () -> getRestClient().performRequest("GET", "/_xpack/security/_authenticate")); assertThat(e.getResponse().getStatusLine().getStatusCode(), is(401)); final String basicAuthValue = UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())); response = getRestClient().performRequest("GET", "/", new BasicHeader("Authorization", basicAuthValue)); assertThat(response.getStatusLine().getStatusCode(), is(200)); - response = getRestClient() - .performRequest("GET", "/_xpack/security/_authenticate", new BasicHeader("Authorization", basicAuthValue)); + response = getRestClient().performRequest("GET", "/_xpack/security/_authenticate", + new BasicHeader("Authorization", basicAuthValue)); assertThat(response.getStatusLine().getStatusCode(), is(200)); } public void testSecurityActionsByLicenseType() throws Exception { // security actions should not work! - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + Settings settings = internalCluster().transportClient().settings(); + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateSecurity.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); new SecurityClient(client).prepareGetUsers().get(); fail("security actions should not be enabled!"); @@ -214,7 +218,7 @@ public class LicensingTests extends SecurityIntegTestCase { License.OperationMode.PLATINUM, License.OperationMode.STANDARD); enableLicensing(mode); // security actions should not work! - try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateSecurity.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); GetUsersResponse response = new SecurityClient(client).prepareGetUsers().get(); assertNotNull(response); @@ -225,11 +229,11 @@ public class LicensingTests extends SecurityIntegTestCase { Settings.Builder builder = Settings.builder() .put(internalCluster().transportClient().settings()); // remove user info - builder.remove(Security.USER_SETTING.getKey()); + builder.remove(SecurityField.USER_SETTING.getKey()); builder.remove(ThreadContext.PREFIX + "." + UsernamePasswordToken.BASIC_AUTH_HEADER); // basic has no auth - try (TransportClient client = new TestXPackTransportClient(builder.build())) { + try (TransportClient client = new TestXPackTransportClient(builder.build(), LocalStateSecurity.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); assertGreenClusterState(client); } @@ -239,7 +243,7 @@ public class LicensingTests extends SecurityIntegTestCase { License.OperationMode.PLATINUM, License.OperationMode.STANDARD); enableLicensing(mode); - try (TransportClient client = new TestXPackTransportClient(builder.build())) { + try (TransportClient client = new TestXPackTransportClient(builder.build(), LocalStateSecurity.class)) { client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.admin().cluster().prepareHealth().get(); fail("should not have been able to connect to a node!"); @@ -250,7 +254,7 @@ public class LicensingTests extends SecurityIntegTestCase { private static void assertElasticsearchSecurityException(ThrowingRunnable runnable) { ElasticsearchSecurityException ee = expectThrows(ElasticsearchSecurityException.class, runnable); - assertThat(ee.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XpackField.SECURITY)); + assertThat(ee.getMetadata(LicenseUtils.EXPIRED_FEATURE_METADATA), hasItem(XPackField.SECURITY)); assertThat(ee.status(), is(RestStatus.FORBIDDEN)); } diff --git a/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java b/plugin/security/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java rename to plugin/security/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java index a8a202ed2c3..ec3c5bbdb70 100644 --- a/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java @@ -7,8 +7,7 @@ package org.elasticsearch.license; import org.elasticsearch.license.License.OperationMode; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.XPackField; import org.hamcrest.Matchers; import java.util.Arrays; @@ -177,38 +176,38 @@ public class XPackLicenseStateTests extends ESTestCase { public void testSecurityAckBasicToNotGoldOrStandard() { OperationMode toMode = randomFrom(OperationMode.values(), mode -> mode != GOLD && mode != STANDARD); - assertAckMesssages(XpackField.SECURITY, BASIC, toMode, 0); + assertAckMesssages(XPackField.SECURITY, BASIC, toMode, 0); } public void testSecurityAckAnyToTrialOrPlatinum() { - assertAckMesssages(XpackField.SECURITY, randomMode(), randomTrialOrPlatinumMode(), 0); + assertAckMesssages(XPackField.SECURITY, randomMode(), randomTrialOrPlatinumMode(), 0); } public void testSecurityAckTrialStandardGoldOrPlatinumToBasic() { - assertAckMesssages(XpackField.SECURITY, randomTrialStandardGoldOrPlatinumMode(), BASIC, 3); + assertAckMesssages(XPackField.SECURITY, randomTrialStandardGoldOrPlatinumMode(), BASIC, 3); } public void testSecurityAckAnyToStandard() { OperationMode from = randomFrom(BASIC, GOLD, PLATINUM, TRIAL); - assertAckMesssages(XpackField.SECURITY, from, STANDARD, 4); + assertAckMesssages(XPackField.SECURITY, from, STANDARD, 4); } public void testSecurityAckBasicStandardTrialOrPlatinumToGold() { OperationMode from = randomFrom(BASIC, PLATINUM, TRIAL, STANDARD); - assertAckMesssages(XpackField.SECURITY, from, GOLD, 2); + assertAckMesssages(XPackField.SECURITY, from, GOLD, 2); } public void testMonitoringAckBasicToAny() { - assertAckMesssages(Monitoring.NAME, BASIC, randomMode(), 0); + assertAckMesssages(XPackField.MONITORING, BASIC, randomMode(), 0); } public void testMonitoringAckAnyToTrialGoldOrPlatinum() { - assertAckMesssages(Monitoring.NAME, randomMode(), randomTrialStandardGoldOrPlatinumMode(), 0); + assertAckMesssages(XPackField.MONITORING, randomMode(), randomTrialStandardGoldOrPlatinumMode(), 0); } public void testMonitoringAckNotBasicToBasic() { OperationMode from = randomFrom(STANDARD, GOLD, PLATINUM, TRIAL); - assertAckMesssages(Monitoring.NAME, from, BASIC, 2); + assertAckMesssages(XPackField.MONITORING, from, BASIC, 2); } public void testMonitoringAllowed() { diff --git a/plugin/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java b/plugin/security/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java index 14f8d61c520..ff9bc87c955 100644 --- a/plugin/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java +++ b/plugin/security/src/test/java/org/elasticsearch/test/NativeRealmIntegTestCase.java @@ -16,7 +16,7 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; -import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.client.SecurityClient; import org.elasticsearch.xpack.security.user.ElasticUser; @@ -65,11 +65,11 @@ public abstract class NativeRealmIntegTestCase extends SecurityIntegTestCase { @Override public Set excludeTemplates() { Set templates = Sets.newHashSet(super.excludeTemplates()); - templates.add(SecurityLifecycleService.SECURITY_TEMPLATE_NAME); // don't remove the security index template + templates.add(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME); // don't remove the security index template return templates; } - private SecureString reservedPassword = SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; + private SecureString reservedPassword = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; protected SecureString getReservedPassword() { return reservedPassword; diff --git a/plugin/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java b/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java similarity index 93% rename from plugin/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java index c6432fe6932..4c59cd7b2c8 100644 --- a/plugin/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java +++ b/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.test; +import org.bouncycastle.operator.OperatorCreationException; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; @@ -20,6 +21,7 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.metadata.AliasOrIndex; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.settings.MockSecureSettings; import org.elasticsearch.common.settings.SecureString; @@ -34,18 +36,26 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.XPackClient; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; +import org.elasticsearch.xpack.security.LocalStateSecurity; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.client.SecurityClient; +import org.elasticsearch.xpack.ssl.SSLService; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.rules.ExternalResource; +import javax.security.auth.DestroyFailedException; +import java.io.IOException; import java.net.InetSocketAddress; import java.nio.file.Path; +import java.security.GeneralSecurityException; +import java.time.Clock; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -54,7 +64,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; -import static org.elasticsearch.test.SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; +import static org.elasticsearch.test.SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_INDEX_NAME; @@ -82,6 +92,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { */ private static CustomSecuritySettingsSource customSecuritySettingsSource = null; + @BeforeClass public static void generateBootstrapPassword() { BOOTSTRAP_PASSWORD = TEST_PASSWORD_SECURE_STRING.clone(); @@ -183,22 +194,26 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { @Before //before methods from the superclass are run before this, which means that the current cluster is ready to go public void assertXPackIsInstalled() { + doAssertXPackIsInstalled(); + } + + protected void doAssertXPackIsInstalled() { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); for (NodeInfo nodeInfo : nodeInfos.getNodes()) { // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? // assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2)); Collection pluginNames = - nodeInfo.getPlugins().getPluginInfos().stream().map(p -> p.getClassname()).collect(Collectors.toList()); - assertThat("plugin [" + xpackPluginClass().getName() + "] not found in [" + pluginNames + "]", pluginNames, - hasItem(xpackPluginClass().getName())); + nodeInfo.getPlugins().getPluginInfos().stream().map(p -> p.getClassname()).collect(Collectors.toList()); + assertThat("plugin [" + LocalStateSecurity.class.getName() + "] not found in [" + pluginNames + "]", pluginNames, + hasItem(LocalStateSecurity.class.getName())); } } @Override protected Settings nodeSettings(int nodeOrdinal) { - Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal)) - // Disable native ML autodetect_process as the c++ controller won't be available - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal)); + // Disable native ML autodetect_process as the c++ controller won't be available +// builder.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); Settings customSettings = customSecuritySettingsSource.nodeSettings(nodeOrdinal); builder.put(customSettings, false); // handle secure settings separately Settings.Builder customBuilder = Settings.builder().put(customSettings); @@ -243,8 +258,8 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { @Override protected Settings externalClusterClientSettings() { return Settings.builder() - .put(Security.USER_SETTING.getKey(), SecuritySettingsSource.TEST_USER_NAME + ":" - + SecuritySettingsSource.TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), SecuritySettingsSource.TEST_USER_NAME + ":" + + SecuritySettingsSourceField.TEST_PASSWORD) .build(); } @@ -319,10 +334,6 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { return defaultMaxNumberOfNodes(); } - protected Class xpackPluginClass() { - return SECURITY_DEFAULT_SETTINGS.xpackPluginClass(); - } - private class CustomSecuritySettingsSource extends SecuritySettingsSource { private CustomSecuritySettingsSource(boolean sslEnabled, Path configDir, Scope scope) { @@ -363,11 +374,6 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { protected SecureString transportClientPassword() { return SecurityIntegTestCase.this.transportClientPassword(); } - - @Override - protected Class xpackPluginClass() { - return SecurityIntegTestCase.this.xpackPluginClass(); - } } protected static void assertGreenClusterState(Client client) { @@ -466,7 +472,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { protected void deleteSecurityIndex() { final Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_SUPERUSER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); GetIndexRequest getIndexRequest = new GetIndexRequest(); getIndexRequest.indices(SECURITY_INDEX_NAME); getIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); diff --git a/plugin/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java b/plugin/security/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java rename to plugin/security/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java index 19aa1bbbd8a..cbe56340abd 100644 --- a/plugin/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java +++ b/plugin/security/src/test/java/org/elasticsearch/test/SecuritySettingsSource.java @@ -20,14 +20,14 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration; import org.elasticsearch.transport.Netty4Plugin; -import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; -import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; import org.elasticsearch.xpack.security.authc.support.Hasher; import org.elasticsearch.xpack.security.test.SecurityTestUtils; @@ -55,9 +55,8 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas public static final Settings DEFAULT_SETTINGS = Settings.EMPTY; public static final String TEST_USER_NAME = "test_user"; - public static final String TEST_PASSWORD = "x-pack-test-password"; - public static final SecureString TEST_PASSWORD_SECURE_STRING = new SecureString("x-pack-test-password".toCharArray()); - public static final String TEST_PASSWORD_HASHED = new String(Hasher.BCRYPT.hash(new SecureString(TEST_PASSWORD.toCharArray()))); + public static final String TEST_PASSWORD_HASHED = + new String(Hasher.BCRYPT.hash(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); public static final String TEST_ROLE = "user"; public static final String TEST_SUPERUSER = "test_superuser"; @@ -112,7 +111,7 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas public Settings nodeSettings(int nodeOrdinal) { final Path home = nodePath(parentFolder, subfolderPrefix, nodeOrdinal); SecurityTestUtils.createFolder(home); - final Path xpackConf = home.resolve("config").resolve(XpackField.NAME); + final Path xpackConf = home.resolve("config").resolve(XPackField.NAME); SecurityTestUtils.createFolder(xpackConf); writeFile(xpackConf, "users", configUsers()); writeFile(xpackConf, "users_roles", configUsersRoles()); @@ -122,15 +121,15 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas //TODO: for now isolate security tests from watcher & monitoring (randomize this later) .put(XPackSettings.WATCHER_ENABLED.getKey(), false) .put(XPackSettings.MONITORING_ENABLED.getKey(), false) - .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) +// .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) +// .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .put(XPackSettings.AUDIT_ENABLED.getKey(), randomBoolean()) .put(LoggingAuditTrail.HOST_ADDRESS_SETTING.getKey(), randomBoolean()) .put(LoggingAuditTrail.HOST_NAME_SETTING.getKey(), randomBoolean()) .put(LoggingAuditTrail.NODE_NAME_SETTING.getKey(), randomBoolean()) - .put("xpack.security.authc.realms.file.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.file.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.file.order", 0) - .put("xpack.security.authc.realms.index.type", NativeRealm.TYPE) + .put("xpack.security.authc.realms.index.type", NativeRealmSettings.TYPE) .put("xpack.security.authc.realms.index.order", "1"); addNodeSSLSettings(builder); return builder.build(); @@ -149,7 +148,7 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas addDefaultSecurityTransportType(builder, superSettings); if (randomBoolean()) { - builder.put(Security.USER_SETTING.getKey(), + builder.put(SecurityField.USER_SETTING.getKey(), transportClientUsername() + ":" + new String(transportClientPassword().getChars())); } else { builder.put(ThreadContext.PREFIX + ".Authorization", basicAuthHeaderValue(transportClientUsername(), @@ -160,18 +159,19 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas protected void addDefaultSecurityTransportType(Settings.Builder builder, Settings settings) { if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings) == false) { - builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), Security.NAME4); + builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), SecurityField.NAME4); } } + @Override public Collection> nodePlugins() { - return Arrays.asList(xpackPluginClass(), Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class); + return Arrays.asList(LocalStateSecurity.class, Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class); } @Override public Collection> transportClientPlugins() { - return nodePlugins(); + return Arrays.asList(XPackClientPlugin.class, Netty4Plugin.class, ReindexPlugin.class, CommonAnalysisPlugin.class); } protected String configUsers() { @@ -191,7 +191,7 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas } protected SecureString nodeClientPassword() { - return new SecureString(TEST_PASSWORD.toCharArray()); + return new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()); } protected String transportClientUsername() { @@ -199,11 +199,7 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas } protected SecureString transportClientPassword() { - return new SecureString(TEST_PASSWORD.toCharArray()); - } - - protected Class xpackPluginClass() { - return XPackPlugin.class; + return new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()); } private void addNodeSSLSettings(Settings.Builder builder) { diff --git a/plugin/src/test/java/org/elasticsearch/test/SecurityTestsUtils.java b/plugin/security/src/test/java/org/elasticsearch/test/SecurityTestsUtils.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/test/SecurityTestsUtils.java rename to plugin/security/src/test/java/org/elasticsearch/test/SecurityTestsUtils.java diff --git a/plugin/src/test/java/org/elasticsearch/transport/SecurityServerTransportServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/transport/SecurityServerTransportServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/transport/SecurityServerTransportServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/transport/SecurityServerTransportServiceTests.java diff --git a/plugin/security/src/test/java/org/elasticsearch/xpack/security/LocalStateSecurity.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/LocalStateSecurity.java new file mode 100644 index 00000000000..be57cf186b6 --- /dev/null +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/LocalStateSecurity.java @@ -0,0 +1,58 @@ +/* + * 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; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.LicenseService; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; + +import java.nio.file.Path; + +public class LocalStateSecurity extends LocalStateCompositeXPackPlugin { + + public LocalStateSecurity(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + LocalStateSecurity thisVar = this; + plugins.add(new Monitoring(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected LicenseService getLicenseService() { + return thisVar.getLicenseService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Security(settings, configPath) { + @Override + protected SSLService getSslService() { return thisVar.getSslService(); } + + @Override + protected XPackLicenseState getLicenseState() { return thisVar.getLicenseState(); } + }); + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java index dcb0ae0fbaf..bfe79bc9fbc 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/PkiRealmBootstrapCheckTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.security.authc.pki.PkiRealm; +import org.elasticsearch.xpack.security.authc.pki.PkiRealmSettings; import org.elasticsearch.xpack.ssl.SSLService; public class PkiRealmBootstrapCheckTests extends ESTestCase { @@ -23,7 +23,7 @@ public class PkiRealmBootstrapCheckTests extends ESTestCase { public void testBootstrapCheckWithPkiRealm() throws Exception { Settings settings = Settings.builder() - .put("xpack.security.authc.realms.test_pki.type", PkiRealm.TYPE) + .put("xpack.security.authc.realms.test_pki.type", PkiRealmSettings.TYPE) .put("path.home", createTempDir()) .build(); Environment env = TestEnvironment.newEnvironment(settings); @@ -81,7 +81,7 @@ public class PkiRealmBootstrapCheckTests extends ESTestCase { public void testBootstrapCheckWithDisabledRealm() throws Exception { Settings settings = Settings.builder() - .put("xpack.security.authc.realms.test_pki.type", PkiRealm.TYPE) + .put("xpack.security.authc.realms.test_pki.type", PkiRealmSettings.TYPE) .put("xpack.security.authc.realms.test_pki.enabled", false) .put("xpack.ssl.client_authentication", "none") .put("path.home", createTempDir()) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/ScrollHelperIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/ScrollHelperIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/ScrollHelperIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/ScrollHelperIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityContextTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityContextTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecurityContextTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityContextTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java index 7f12001fc1c..30ed863e4e8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityFeatureSetTests.java @@ -17,7 +17,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.authc.Realms; import org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; @@ -163,10 +163,10 @@ public class SecurityFeatureSetTests extends ESTestCase { XPackFeatureSet.Usage securityUsage = future.get(); BytesStreamOutput out = new BytesStreamOutput(); securityUsage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new SecurityFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new SecurityFeatureSetUsage(out.bytes().streamInput()); for (XPackFeatureSet.Usage usage : Arrays.asList(securityUsage, serializedUsage)) { assertThat(usage, is(notNullValue())); - assertThat(usage.name(), is(XpackField.SECURITY)); + assertThat(usage.name(), is(XPackField.SECURITY)); assertThat(usage.enabled(), is(enabled)); assertThat(usage.available(), is(authcAuthzAvailable)); XContentSource source; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java index b64f40f673d..a5249ebe873 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityLifecycleServiceTests.java @@ -43,7 +43,7 @@ import org.junit.After; import org.junit.Before; import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_INDEX_NAME; -import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.security.SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME; import static org.elasticsearch.xpack.security.SecurityLifecycleService.securityIndexMappingUpToDate; import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; @@ -105,10 +105,10 @@ public class SecurityLifecycleServiceTests extends ESTestCase { final ClusterState clusterState = clusterStateBuilder.build(); assertTrue(IndexLifecycleManager.checkTemplateExistsAndVersionMatches( - SecurityLifecycleService.SECURITY_TEMPLATE_NAME, clusterState, logger, + SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME, clusterState, logger, Version.V_5_0_0::before)); assertFalse(IndexLifecycleManager.checkTemplateExistsAndVersionMatches( - SecurityLifecycleService.SECURITY_TEMPLATE_NAME, clusterState, logger, + SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME, clusterState, logger, Version.V_5_0_0::after)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java index 8d51ce144a8..4617e9f3e49 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityPluginTests.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import java.io.IOException; @@ -44,7 +45,7 @@ public class SecurityPluginTests extends SecurityIntegTestCase { Response response = getRestClient().performRequest("GET", "/_xpack", new BasicHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())))); assertThat(response.getStatusLine().getStatusCode(), is(OK.getStatus())); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java index 2c82dfe1d97..7e2a0e01505 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecuritySettingsTests.java @@ -8,8 +8,8 @@ package org.elasticsearch.xpack.security; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.security.audit.index.IndexAuditTrailField; import java.util.Collections; @@ -32,7 +32,7 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.on_conflict", "prefer_t1") .build(); - Settings additionalSettings = Security.additionalSettings(settings, false); + Settings additionalSettings = Security.additionalSettings(settings, true, false); assertThat(additionalSettings.getAsBoolean(TRIBE_T1_SECURITY_ENABLED, null), equalTo(true)); assertThat(additionalSettings.getAsBoolean(TRIBE_T2_SECURITY_ENABLED, null), equalTo(true)); @@ -44,7 +44,7 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.t2.cluster.name", "non_existing").build(); try { - Security.additionalSettings(settings, false); + Security.additionalSettings(settings, true, false); fail("security cannot change the value of a setting that is already defined, so a exception should be thrown"); } catch (IllegalStateException e) { assertThat(e.getMessage(), containsString(TRIBE_T1_SECURITY_ENABLED)); @@ -55,10 +55,10 @@ public class SecuritySettingsTests extends ESTestCase { Settings settings = Settings.builder().put("tribe.t1.cluster.name", "non_existing") .put(TRIBE_T1_SECURITY_ENABLED, false) .put("tribe.t2.cluster.name", "non_existing") - .putList("tribe.t1.plugin.mandatory", "test_plugin", XpackField.NAME).build(); + .putList("tribe.t1.plugin.mandatory", "test_plugin", XPackField.NAME).build(); try { - Security.additionalSettings(settings, false); + Security.additionalSettings(settings, true, false); fail("security cannot change the value of a setting that is already defined, so a exception should be thrown"); } catch (IllegalStateException e) { assertThat(e.getMessage(), containsString(TRIBE_T1_SECURITY_ENABLED)); @@ -75,7 +75,7 @@ public class SecuritySettingsTests extends ESTestCase { .putList("xpack.security.something.else.here", new String[] { "foo", "bar" }) .build(); - Settings additionalSettings = Security.additionalSettings(settings, false); + Settings additionalSettings = Security.additionalSettings(settings, true, false); assertThat(additionalSettings.get("xpack.security.foo"), nullValue()); assertThat(additionalSettings.get("xpack.security.bar"), nullValue()); @@ -97,15 +97,15 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.t2.cluster.name", "non_existing2") .build(); - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(settings, false)); + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(settings, true, false)); assertThat(e.getMessage(), containsString("tribe.on_conflict")); final Settings badOnConflict = Settings.builder().put(settings).put("tribe.on_conflict", randomFrom("any", "drop")).build(); - e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(badOnConflict, false)); + e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(badOnConflict, true, false)); assertThat(e.getMessage(), containsString("tribe.on_conflict")); Settings goodOnConflict = Settings.builder().put(settings).put("tribe.on_conflict", "prefer_" + randomFrom("t1", "t2")).build(); - Settings additionalSettings = Security.additionalSettings(goodOnConflict, false); + Settings additionalSettings = Security.additionalSettings(goodOnConflict, true, false); assertNotNull(additionalSettings); } @@ -116,7 +116,7 @@ public class SecuritySettingsTests extends ESTestCase { .put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false) .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAlphaOfLengthBetween(1, 6))) .build(); - Settings additionalSettings = Security.additionalSettings(noNative, false); + Settings additionalSettings = Security.additionalSettings(noNative, true, false); assertNotNull(additionalSettings); // still with the reserved realm @@ -125,7 +125,9 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.t2.cluster.name", "non_existing2") .put("xpack.security.authc.realms.foo.type", randomFrom("ldap", "pki", randomAlphaOfLengthBetween(1, 6))) .build(); - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(withReserved, false)); + IllegalArgumentException e = expectThrows( + IllegalArgumentException.class, + () -> Security.additionalSettings(withReserved, true, false)); assertThat(e.getMessage(), containsString("tribe.on_conflict")); // reserved disabled but no realms defined @@ -134,7 +136,7 @@ public class SecuritySettingsTests extends ESTestCase { .put("tribe.t2.cluster.name", "non_existing2") .put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false) .build(); - e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(reservedDisabled, false)); + e = expectThrows(IllegalArgumentException.class, () -> Security.additionalSettings(reservedDisabled, true, false)); assertThat(e.getMessage(), containsString("tribe.on_conflict")); } @@ -162,7 +164,7 @@ public class SecuritySettingsTests extends ESTestCase { .build()); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), containsString(IndexAuditTrail.INDEX_NAME_PREFIX)); + assertThat(e.getMessage(), containsString(IndexAuditTrailField.INDEX_NAME_PREFIX)); } Security.validateAutoCreateIndex(Settings.builder() diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java index e8fe71aa653..08969555cbb 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.license.License; import org.elasticsearch.license.TestUtils; +import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -36,9 +37,9 @@ import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; import org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail; import org.elasticsearch.xpack.security.authc.Realm; import org.elasticsearch.xpack.security.authc.Realms; -import org.elasticsearch.xpack.security.authc.file.FileRealm; -import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; -import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.FieldPermissions; import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsDefinition; @@ -100,10 +101,21 @@ public class SecurityTests extends ESTestCase { Settings settings = Settings.builder().put(testSettings).put("path.home", createTempDir()).build(); Environment env = TestEnvironment.newEnvironment(settings); licenseState = new TestUtils.UpdatableLicenseState(); - security = new Security(settings, env, licenseState, new SSLService(settings, env)); + SSLService sslService = new SSLService(settings, env); + security = new Security(settings, null) { + @Override + protected XPackLicenseState getLicenseState() { + return licenseState; + } + + @Override + protected SSLService getSslService() { + return sslService; + } + }; ThreadPool threadPool = mock(ThreadPool.class); ClusterService clusterService = mock(ClusterService.class); - settings = Security.additionalSettings(settings, false); + settings = Security.additionalSettings(settings, true, false); Set> allowedSettings = new HashSet<>(Security.getSettings(false, null)); allowedSettings.addAll(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); ClusterSettings clusterSettings = new ClusterSettings(settings, allowedSettings); @@ -145,8 +157,8 @@ public class SecurityTests extends ESTestCase { public void testCustomRealmExtensionConflict() throws Exception { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> createComponents(Settings.EMPTY, new DummyExtension(FileRealm.TYPE))); - assertEquals("Realm type [" + FileRealm.TYPE + "] is already registered", e.getMessage()); + () -> createComponents(Settings.EMPTY, new DummyExtension(FileRealmSettings.TYPE))); + assertEquals("Realm type [" + FileRealmSettings.TYPE + "] is already registered", e.getMessage()); } @@ -196,17 +208,17 @@ public class SecurityTests extends ESTestCase { assertEquals("Unknown audit trail output [foo]", e.getMessage()); } - public void testTransportSettingDefaults() throws Exception { - Settings defaultSettings = Security.additionalSettings(Settings.EMPTY, false); - assertEquals(Security.NAME4, NetworkModule.TRANSPORT_TYPE_SETTING.get(defaultSettings)); - assertEquals(Security.NAME4, NetworkModule.HTTP_TYPE_SETTING.get(defaultSettings)); + public void testHttpSettingDefaults() throws Exception { + final Settings defaultSettings = Security.additionalSettings(Settings.EMPTY, true, false); + assertThat(SecurityField.NAME4, equalTo(NetworkModule.TRANSPORT_TYPE_SETTING.get(defaultSettings))); + assertThat(SecurityField.NAME4, equalTo(NetworkModule.HTTP_TYPE_SETTING.get(defaultSettings))); } public void testTransportSettingNetty4Both() { Settings both4 = Security.additionalSettings(Settings.builder() - .put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4) - .put(NetworkModule.HTTP_TYPE_KEY, Security.NAME4) - .build(), false); + .put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4) + .put(NetworkModule.HTTP_TYPE_KEY, SecurityField.NAME4) + .build(), true, false); assertFalse(NetworkModule.TRANSPORT_TYPE_SETTING.exists(both4)); assertFalse(NetworkModule.HTTP_TYPE_SETTING.exists(both4)); } @@ -215,23 +227,23 @@ public class SecurityTests extends ESTestCase { final String badType = randomFrom("netty4", "other", "security1"); Settings settingsTransport = Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, badType).build(); IllegalArgumentException badTransport = expectThrows(IllegalArgumentException.class, - () -> Security.additionalSettings(settingsTransport, false)); - assertThat(badTransport.getMessage(), containsString(Security.NAME4)); + () -> Security.additionalSettings(settingsTransport, true, false)); + assertThat(badTransport.getMessage(), containsString(SecurityField.NAME4)); assertThat(badTransport.getMessage(), containsString(NetworkModule.TRANSPORT_TYPE_KEY)); Settings settingsHttp = Settings.builder().put(NetworkModule.HTTP_TYPE_KEY, badType).build(); IllegalArgumentException badHttp = expectThrows(IllegalArgumentException.class, - () -> Security.additionalSettings(settingsHttp, false)); - assertThat(badHttp.getMessage(), containsString(Security.NAME4)); + () -> Security.additionalSettings(settingsHttp, true, false)); + assertThat(badHttp.getMessage(), containsString(SecurityField.NAME4)); assertThat(badHttp.getMessage(), containsString(NetworkModule.HTTP_TYPE_KEY)); } public void testSettingFilter() throws Exception { createComponents(Settings.EMPTY); - final List filter = security.getSettingsFilter(null); + final List filter = security.getSettingsFilter(); assertThat(filter, hasItem(SecurityField.setting("authc.realms.*.bind_dn"))); assertThat(filter, hasItem(SecurityField.setting("authc.realms.*.bind_password"))); - assertThat(filter, hasItem(SecurityField.setting("authc.realms.*." + SessionFactory.HOSTNAME_VERIFICATION_SETTING))); + assertThat(filter, hasItem(SecurityField.setting("authc.realms.*." + SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING))); assertThat(filter, hasItem(SecurityField.setting("authc.realms.*.ssl.truststore.password"))); assertThat(filter, hasItem(SecurityField.setting("authc.realms.*.ssl.truststore.path"))); assertThat(filter, hasItem(SecurityField.setting("authc.realms.*.ssl.truststore.algorithm"))); @@ -357,7 +369,7 @@ public class SecurityTests extends ESTestCase { new IndicesAccessControl.IndexAccessControl(true, null, Collections.emptySet()); permissionsMap.put("index_null", nullFieldPermissions); IndicesAccessControl index = new IndicesAccessControl(true, permissionsMap); - threadContext.putTransient(AuthorizationService.INDICES_PERMISSIONS_KEY, index); + threadContext.putTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, index); assertTrue(fieldFilter.apply("index_granted").test("field_granted")); assertFalse(fieldFilter.apply("index_granted").test(randomAlphaOfLengthBetween(3, 10))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/TemplateUpgraderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/TemplateUpgraderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/TemplateUpgraderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/TemplateUpgraderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/TokenSSLBootsrapCheckTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/TokenSSLBootsrapCheckTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/TokenSSLBootsrapCheckTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/TokenSSLBootsrapCheckTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/SecurityActionMapperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/filter/DestructiveOperationsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/DestructiveOperationsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/filter/DestructiveOperationsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/DestructiveOperationsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java index 9fa224a909f..e96a12a00ab 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/IndicesAliasesRequestInterceptorTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.FieldPermissions; import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsDefinition; @@ -56,7 +57,7 @@ public class IndicesAliasesRequestInterceptorTests extends ESTestCase { final String action = IndicesAliasesAction.NAME; IndicesAccessControl accessControl = new IndicesAccessControl(true, Collections.singletonMap("foo", new IndicesAccessControl.IndexAccessControl(true, fieldPermissions, queries))); - threadContext.putTransient(AuthorizationService.INDICES_PERMISSIONS_KEY, accessControl); + threadContext.putTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, accessControl); IndicesAliasesRequestInterceptor interceptor = new IndicesAliasesRequestInterceptor(threadContext, licenseState, auditTrailService); @@ -88,7 +89,7 @@ public class IndicesAliasesRequestInterceptorTests extends ESTestCase { .build(); final String action = IndicesAliasesAction.NAME; IndicesAccessControl accessControl = new IndicesAccessControl(true, Collections.emptyMap()); - threadContext.putTransient(AuthorizationService.INDICES_PERMISSIONS_KEY, accessControl); + threadContext.putTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, accessControl); IndicesAliasesRequestInterceptor interceptor = new IndicesAliasesRequestInterceptor(threadContext, licenseState, auditTrailService); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java index ed03d8d928a..8e90bf804be 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/interceptor/ResizeRequestInterceptorTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.elasticsearch.xpack.security.authz.AuthorizationService; +import org.elasticsearch.xpack.security.authz.AuthorizationServiceField; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.FieldPermissions; import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsDefinition; @@ -60,7 +61,7 @@ public class ResizeRequestInterceptorTests extends ESTestCase { final String action = randomFrom(ShrinkAction.NAME, ResizeAction.NAME); IndicesAccessControl accessControl = new IndicesAccessControl(true, Collections.singletonMap("foo", new IndicesAccessControl.IndexAccessControl(true, fieldPermissions, queries))); - threadContext.putTransient(AuthorizationService.INDICES_PERMISSIONS_KEY, accessControl); + threadContext.putTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, accessControl); ResizeRequestInterceptor resizeRequestInterceptor = new ResizeRequestInterceptor(Settings.EMPTY, threadPool, licenseState, auditTrailService); @@ -86,7 +87,7 @@ public class ResizeRequestInterceptorTests extends ESTestCase { .build(); final String action = randomFrom(ShrinkAction.NAME, ResizeAction.NAME); IndicesAccessControl accessControl = new IndicesAccessControl(true, Collections.emptyMap()); - threadContext.putTransient(AuthorizationService.INDICES_PERMISSIONS_KEY, accessControl); + threadContext.putTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY, accessControl); ResizeRequestInterceptor resizeRequestInterceptor = new ResizeRequestInterceptor(Settings.EMPTY, threadPool, licenseState, auditTrailService); ElasticsearchSecurityException securityException = expectThrows(ElasticsearchSecurityException.class, diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/PutRoleBuilderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/PutRoleBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/role/PutRoleBuilderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/PutRoleBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/PutRoleMappingRequestTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/PutRoleMappingRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/PutRoleMappingRequestTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/PutRoleMappingRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/token/CreateTokenRequestTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/CreateTokenRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/token/CreateTokenRequestTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/CreateTokenRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestBuilderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestBuilderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestBuilderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestBuilderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/PutUserRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java index 00738e9d360..2f425c2247e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; import org.elasticsearch.xpack.security.authc.support.Hasher; import org.elasticsearch.xpack.security.user.AnonymousUser; @@ -55,7 +55,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { ChangePasswordRequest request = new ChangePasswordRequest(); request.username(anonymousUser.principal()); - request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final AtomicReference throwableRef = new AtomicReference<>(); final AtomicReference responseRef = new AtomicReference<>(); @@ -86,7 +86,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { ChangePasswordRequest request = new ChangePasswordRequest(); request.username(randomFrom(SystemUser.INSTANCE.principal(), XPackUser.INSTANCE.principal())); - request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final AtomicReference throwableRef = new AtomicReference<>(); final AtomicReference responseRef = new AtomicReference<>(); @@ -113,7 +113,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { NativeUsersStore usersStore = mock(NativeUsersStore.class); ChangePasswordRequest request = new ChangePasswordRequest(); request.username(user.principal()); - request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); doAnswer(invocation -> { Object[] args = invocation.getArguments(); assert args.length == 2; @@ -151,7 +151,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { NativeUsersStore usersStore = mock(NativeUsersStore.class); ChangePasswordRequest request = new ChangePasswordRequest(); request.username(user.principal()); - request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final Exception e = randomFrom(new ElasticsearchSecurityException(""), new IllegalStateException(), new RuntimeException()); doAnswer(new Answer() { public Void answer(InvocationOnMock invocation) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java index e5cd778ce79..69accf2e53b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.SecurityLifecycleService; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; @@ -163,7 +163,7 @@ public class TransportPutUserActionTests extends ESTestCase { final PutUserRequest request = new PutUserRequest(); request.username(user.principal()); if (isCreate) { - request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + request.passwordHash(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); } final boolean created = isCreate ? randomBoolean() : false; // updates should always return false for create doAnswer(new Answer() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditLevelTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditLevelTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditLevelTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditLevelTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditTrailServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditTrailServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditTrailServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditTrailServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/AuditUtilTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java index f01638251ea..680c7ac82c8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/AuditTrailTests.java @@ -34,7 +34,7 @@ import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import static org.elasticsearch.test.SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; +import static org.elasticsearch.test.SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -142,7 +142,7 @@ public class AuditTrailTests extends SecurityIntegTestCase { private Collection> getAuditEvents() throws Exception { final Client client = client(); DateTime now = new DateTime(DateTimeZone.UTC); - String indexName = IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, now, IndexNameResolver.Rollover.DAILY); + String indexName = IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, now, IndexNameResolver.Rollover.DAILY); assertTrue(awaitBusy(() -> indexExists(client, indexName), 5, TimeUnit.SECONDS)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailMutedTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java index 9655114c065..33683184fef 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrailTests.java @@ -36,21 +36,24 @@ import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportInfo; import org.elasticsearch.transport.TransportMessage; import org.elasticsearch.transport.TransportRequest; -import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail.Message; import org.elasticsearch.xpack.security.authc.AuthenticationToken; import org.elasticsearch.xpack.security.transport.filter.IPFilter; import org.elasticsearch.xpack.security.transport.filter.SecurityIpFilterRule; import org.elasticsearch.xpack.security.user.SystemUser; import org.elasticsearch.xpack.security.user.User; +import org.elasticsearch.xpack.watcher.Watcher; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; @@ -62,7 +65,6 @@ import org.junit.BeforeClass; import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -86,6 +88,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + @ESIntegTestCase.ClusterScope(scope = SUITE, supportsDedicatedMasters = false, numDataNodes = 1) public class IndexAuditTrailTests extends SecurityIntegTestCase { public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX; @@ -174,7 +177,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { .put("xpack.security.audit.index.settings.index.number_of_shards", numShards) .put("xpack.security.audit.index.settings.index.number_of_replicas", numReplicas) // Disable native ML autodetect_process as the c++ controller won't be available - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) +// .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity); if (useSecurity == false && builder.get(NetworkModule.TRANSPORT_TYPE_KEY) == null) { builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()); @@ -223,7 +226,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { .put("xpack.security.audit.index.client." + XPackSettings.SECURITY_ENABLED.getKey(), useSecurity) .put(remoteSettings(NetworkAddress.format(inet.address().getAddress()), inet.address().getPort(), cluster2Name)) .put("xpack.security.audit.index.client.xpack.security.user", SecuritySettingsSource.TEST_USER_NAME + ":" + - SecuritySettingsSource.TEST_PASSWORD); + SecuritySettingsSourceField.TEST_PASSWORD); if (remoteUseSSL) { cluster2SettingsSource.addClientSSLSettings(builder, "xpack.security.audit.index.client."); @@ -251,7 +254,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { @Override protected Set excludeTemplates() { - return Sets.newHashSet(SecurityLifecycleService.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME); + return Sets.newHashSet(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME); } @Override @@ -342,6 +345,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { threadPool = new TestThreadPool("index audit trail tests"); enqueuedMessage = new SetOnce<>(); auditor = new IndexAuditTrail(settings, client(), threadPool, clusterService) { + @Override void enqueue(Message message, String type) { enqueuedMessage.set(message); @@ -350,7 +354,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { @Override List> remoteTransportClientPlugins() { - return Arrays.asList(XPackPlugin.class, getTestTransportPlugin()); + return Arrays.asList(LocalStateSecurity.class, getTestTransportPlugin()); } }; auditor.start(); @@ -883,7 +887,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase { private SearchHit getIndexedAuditMessage(Message message) throws InterruptedException { assertNotNull("no audit message was enqueued", message); - final String indexName = IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, message.timestamp, rollover); + final String indexName = IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, message.timestamp, rollover); ensureYellow(indexName); GetSettingsResponse settingsResponse = getClient().admin().indices().prepareGetSettings(indexName).get(); assertThat(settingsResponse.getSetting(indexName, "index.number_of_shards"), is(Integer.toString(numShards))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java index 765200a12a6..8d9bc0ca591 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/index/RemoteIndexAuditTrailStartingTests.java @@ -16,9 +16,9 @@ import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.junit.annotations.TestLogging; -import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.elasticsearch.xpack.security.audit.AuditTrail; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.junit.After; @@ -70,7 +70,7 @@ public class RemoteIndexAuditTrailStartingTests extends SecurityIntegTestCase { @Override protected Set excludeTemplates() { - return Sets.newHashSet(SecurityLifecycleService.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME); + return Sets.newHashSet(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME, IndexAuditTrail.INDEX_TEMPLATE_NAME); } @Override @@ -101,12 +101,13 @@ public class RemoteIndexAuditTrailStartingTests extends SecurityIntegTestCase { Settings.Builder builder = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) // Disable native ML autodetect_process as the c++ controller won't be available - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) +// .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .put("xpack.security.audit.enabled", true) .put("xpack.security.audit.outputs", randomFrom("index", "index,logfile")) .putList("xpack.security.audit.index.client.hosts", addresses.toArray(new String[addresses.size()])) .put("xpack.security.audit.index.client.cluster.name", clusterName) - .put("xpack.security.audit.index.client.xpack.security.user", TEST_USER_NAME + ":" + TEST_PASSWORD) + .put("xpack.security.audit.index.client.xpack.security.user", + TEST_USER_NAME + ":" + SecuritySettingsSourceField.TEST_PASSWORD) .put("xpack.security.audit.index.settings.index.number_of_shards", 1) .put("xpack.security.audit.index.settings.index.number_of_replicas", 0); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/CapturingLogger.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/CapturingLogger.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/CapturingLogger.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/CapturingLogger.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java similarity index 79% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java index ce8cc27a2b5..865b1842b6c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/InternalRealmsTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.security.SecurityLifecycleService; import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; import org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore; import org.elasticsearch.xpack.ssl.SSLService; @@ -35,16 +36,16 @@ public class InternalRealmsTests extends ESTestCase { SecurityLifecycleService lifecycleService = mock(SecurityLifecycleService.class); Map factories = InternalRealms.getFactories(mock(ThreadPool.class), mock(ResourceWatcherService.class), mock(SSLService.class), mock(NativeUsersStore.class), mock(NativeRoleMappingStore.class), lifecycleService); - assertThat(factories, hasEntry(is(NativeRealm.TYPE), any(Realm.Factory.class))); + assertThat(factories, hasEntry(is(NativeRealmSettings.TYPE), any(Realm.Factory.class))); verifyZeroInteractions(lifecycleService); Settings settings = Settings.builder().put("path.home", createTempDir()).build(); - factories.get(NativeRealm.TYPE).create(new RealmConfig("test", Settings.EMPTY, settings, TestEnvironment.newEnvironment(settings), - new ThreadContext(settings))); + factories.get(NativeRealmSettings.TYPE).create(new RealmConfig("test", Settings.EMPTY, settings, + TestEnvironment.newEnvironment(settings), new ThreadContext(settings))); verify(lifecycleService).addSecurityIndexHealthChangeListener(isA(BiConsumer.class)); - factories.get(NativeRealm.TYPE).create(new RealmConfig("test", Settings.EMPTY, settings, TestEnvironment.newEnvironment(settings), - new ThreadContext(settings))); + factories.get(NativeRealmSettings.TYPE).create(new RealmConfig("test", Settings.EMPTY, settings, + TestEnvironment.newEnvironment(settings), new ThreadContext(settings))); verify(lifecycleService, times(2)).addSecurityIndexHealthChangeListener(isA(BiConsumer.class)); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmSettingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java similarity index 91% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java index eef03cc210e..e822a2ac75f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java @@ -13,10 +13,11 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.license.XPackLicenseState.AllowedRealmType; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; -import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; import org.elasticsearch.xpack.security.authc.ldap.LdapRealm; +import org.elasticsearch.xpack.security.authc.ldap.LdapRealmSettings; import org.elasticsearch.xpack.security.user.User; import org.junit.Before; @@ -49,8 +50,8 @@ public class RealmsTests extends ESTestCase { @Before public void init() throws Exception { factories = new HashMap<>(); - factories.put(FileRealm.TYPE, config -> new DummyRealm(FileRealm.TYPE, config)); - factories.put(NativeRealm.TYPE, config -> new DummyRealm(NativeRealm.TYPE, config)); + factories.put(FileRealmSettings.TYPE, config -> new DummyRealm(FileRealmSettings.TYPE, config)); + factories.put(NativeRealmSettings.TYPE, config -> new DummyRealm(NativeRealmSettings.TYPE, config)); for (int i = 0; i < randomIntBetween(1, 5); i++) { String name = "type_" + i; factories.put(name, config -> new DummyRealm(name, config)); @@ -138,9 +139,9 @@ public class RealmsTests extends ESTestCase { public void testWithSettingsWithMultipleInternalRealmsOfSameType() throws Exception { Settings settings = Settings.builder() - .put("xpack.security.authc.realms.realm_1.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.realm_1.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.realm_1.order", 0) - .put("xpack.security.authc.realms.realm_2.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.realm_2.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.realm_2.order", 1) .put("path.home", createTempDir()) .build(); @@ -162,12 +163,12 @@ public class RealmsTests extends ESTestCase { assertThat(realm, is(reservedRealm)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(FileRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + FileRealm.TYPE)); + assertThat(realm.type(), equalTo(FileRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + FileRealmSettings.TYPE)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(NativeRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + NativeRealm.TYPE)); + assertThat(realm.type(), equalTo(NativeRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + NativeRealmSettings.TYPE)); assertThat(iter.hasNext(), is(false)); } @@ -212,12 +213,12 @@ public class RealmsTests extends ESTestCase { assertThat(realm, is(reservedRealm)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(FileRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + FileRealm.TYPE)); + assertThat(realm.type(), equalTo(FileRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + FileRealmSettings.TYPE)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(NativeRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + NativeRealm.TYPE)); + assertThat(realm.type(), equalTo(NativeRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + NativeRealmSettings.TYPE)); assertThat(iter.hasNext(), is(false)); when(licenseState.allowedRealmType()).thenReturn(AllowedRealmType.NATIVE); @@ -228,17 +229,17 @@ public class RealmsTests extends ESTestCase { assertThat(realm, is(reservedRealm)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(FileRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + FileRealm.TYPE)); + assertThat(realm.type(), equalTo(FileRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + FileRealmSettings.TYPE)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(NativeRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + NativeRealm.TYPE)); + assertThat(realm.type(), equalTo(NativeRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + NativeRealmSettings.TYPE)); assertThat(iter.hasNext(), is(false)); } public void testUnlicensedWithInternalRealms() throws Exception { - factories.put(LdapRealm.LDAP_TYPE, config -> new DummyRealm(LdapRealm.LDAP_TYPE, config)); + factories.put(LdapRealmSettings.LDAP_TYPE, config -> new DummyRealm(LdapRealmSettings.LDAP_TYPE, config)); assertThat(factories.get("type_0"), notNullValue()); Settings.Builder builder = Settings.builder() .put("path.home", createTempDir()) @@ -284,18 +285,18 @@ public class RealmsTests extends ESTestCase { assertThat(realm, is(reservedRealm)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(FileRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + FileRealm.TYPE)); + assertThat(realm.type(), equalTo(FileRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + FileRealmSettings.TYPE)); assertThat(iter.hasNext(), is(true)); realm = iter.next(); - assertThat(realm.type(), equalTo(NativeRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + NativeRealm.TYPE)); + assertThat(realm.type(), equalTo(NativeRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + NativeRealmSettings.TYPE)); assertThat(iter.hasNext(), is(false)); } - public void testUnlicensedWithNativeRealms() throws Exception { - factories.put(LdapRealm.LDAP_TYPE, config -> new DummyRealm(LdapRealm.LDAP_TYPE, config)); - final String type = randomFrom(FileRealm.TYPE, NativeRealm.TYPE); + public void testUnlicensedWithNativeRealmSettingss() throws Exception { + factories.put(LdapRealmSettings.LDAP_TYPE, config -> new DummyRealm(LdapRealmSettings.LDAP_TYPE, config)); + final String type = randomFrom(FileRealmSettings.TYPE, NativeRealmSettings.TYPE); Settings.Builder builder = Settings.builder() .put("path.home", createTempDir()) .put("xpack.security.authc.realms.foo.type", "ldap") @@ -361,12 +362,12 @@ public class RealmsTests extends ESTestCase { Integer index = orderToIndex.get(realm.order()); if (index == null) { // Default realms are inserted when factories size is 1 and enabled is false - assertThat(realm.type(), equalTo(FileRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + FileRealm.TYPE)); + assertThat(realm.type(), equalTo(FileRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + FileRealmSettings.TYPE)); assertThat(iterator.hasNext(), is(true)); realm = iterator.next(); - assertThat(realm.type(), equalTo(NativeRealm.TYPE)); - assertThat(realm.name(), equalTo("default_" + NativeRealm.TYPE)); + assertThat(realm.type(), equalTo(NativeRealmSettings.TYPE)); + assertThat(realm.name(), equalTo("default_" + NativeRealmSettings.TYPE)); assertThat(iterator.hasNext(), is(false)); } else { assertThat(realm.type(), equalTo("type_" + index)); @@ -382,7 +383,7 @@ public class RealmsTests extends ESTestCase { public void testAuthcAuthzDisabled() throws Exception { Settings settings = Settings.builder() .put("path.home", createTempDir()) - .put("xpack.security.authc.realms.realm_1.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.realm_1.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.realm_1.order", 0) .build(); Environment env = TestEnvironment.newEnvironment(settings); @@ -449,7 +450,7 @@ public class RealmsTests extends ESTestCase { for (Entry entry : usageStats.entrySet()) { final String type = entry.getKey(); Map typeMap = (Map) entry.getValue(); - if (FileRealm.TYPE.equals(type) || NativeRealm.TYPE.equals(type)) { + if (FileRealmSettings.TYPE.equals(type) || NativeRealmSettings.TYPE.equals(type)) { assertThat(typeMap, hasEntry("enabled", true)); assertThat(typeMap, hasEntry("available", true)); assertThat((Iterable) typeMap.get("name"), contains("default_" + type)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java similarity index 90% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java index fb076d8ab1a..d4cc93cb548 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RunAsIntegTests.java @@ -17,11 +17,14 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.xpack.security.Security; -import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.TestXPackTransportClient; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; +import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.junit.BeforeClass; import java.util.Collections; @@ -29,7 +32,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.elasticsearch.test.SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; +import static org.elasticsearch.test.SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; @@ -89,7 +92,8 @@ public class RunAsIntegTests extends SecurityIntegTestCase { public void testUserImpersonation() throws Exception { try (TransportClient client = getTransportClient(Settings.builder() - .put(Security.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + SecuritySettingsSource.TEST_PASSWORD).build())) { + .put(SecurityField.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + + SecuritySettingsSourceField.TEST_PASSWORD).build())) { //ensure the client can connect assertBusy(() -> assertThat(client.connectedNodes().size(), greaterThan(0))); @@ -115,7 +119,7 @@ public class RunAsIntegTests extends SecurityIntegTestCase { Map headers = new HashMap<>(); headers.put("Authorization", UsernamePasswordToken.basicAuthHeaderValue(RUN_AS_USER, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray()))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); headers.put(AuthenticationServiceField.RUN_AS_USER_HEADER, SecuritySettingsSource.TEST_USER_NAME); // lets set the user ClusterHealthResponse response = client.filterWithHeader(headers).admin().cluster().prepareHealth().get(); @@ -160,7 +164,8 @@ public class RunAsIntegTests extends SecurityIntegTestCase { public void testEmptyUserImpersonationHeader() throws Exception { try (TransportClient client = getTransportClient(Settings.builder() - .put(Security.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + SecuritySettingsSource.TEST_PASSWORD).build())) { + .put(SecurityField.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + + SecuritySettingsSourceField.TEST_PASSWORD).build())) { //ensure the client can connect awaitBusy(() -> { return client.connectedNodes().size() > 0; @@ -169,7 +174,7 @@ public class RunAsIntegTests extends SecurityIntegTestCase { try { Map headers = new HashMap<>(); headers.put("Authorization", UsernamePasswordToken.basicAuthHeaderValue(RUN_AS_USER, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray()))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); headers.put(AuthenticationServiceField.RUN_AS_USER_HEADER, ""); client.filterWithHeader(headers).admin().cluster().prepareHealth().get(); @@ -195,7 +200,8 @@ public class RunAsIntegTests extends SecurityIntegTestCase { public void testNonExistentRunAsUser() throws Exception { try (TransportClient client = getTransportClient(Settings.builder() - .put(Security.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + SecuritySettingsSource.TEST_PASSWORD).build())) { + .put(SecurityField.USER_SETTING.getKey(), TRANSPORT_CLIENT_USER + ":" + + SecuritySettingsSourceField.TEST_PASSWORD).build())) { //ensure the client can connect awaitBusy(() -> { return client.connectedNodes().size() > 0; @@ -204,7 +210,7 @@ public class RunAsIntegTests extends SecurityIntegTestCase { try { Map headers = new HashMap<>(); headers.put("Authorization", UsernamePasswordToken.basicAuthHeaderValue(RUN_AS_USER, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray()))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); headers.put(AuthenticationServiceField.RUN_AS_USER_HEADER, "idontexist"); client.filterWithHeader(headers).admin().cluster().prepareHealth().get(); @@ -241,7 +247,7 @@ public class RunAsIntegTests extends SecurityIntegTestCase { .put("cluster.name", clusterName) .build(); - return new TestXPackTransportClient(settings) + return new TestXPackTransportClient(settings, LocalStateSecurity.class) .addTransportAddress(publishAddress); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java index d9206a400bd..76fa95a144f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.security.SecurityLifecycleService; @@ -69,7 +70,7 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { CreateTokenResponse response = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); for (TokenService tokenService : internalCluster().getInstances(TokenService.class)) { PlainActionFuture userTokenFuture = new PlainActionFuture<>(); @@ -97,7 +98,7 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { CreateTokenResponse response = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); String masterName = internalCluster().getMasterName(); TokenService masterTokenService = internalCluster().getInstance(TokenService.class, masterName); @@ -127,12 +128,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testExpiredTokensDeletedAfterExpiration() throws Exception { final Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_SUPERUSER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse response = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); Instant created = Instant.now(); @@ -190,7 +191,7 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { CreateTokenResponse response = securityClient().prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); InvalidateTokenResponse invalidateResponse = securityClient() @@ -208,12 +209,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testRefreshingToken() { Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse createTokenResponse = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); assertNotNull(createTokenResponse.getRefreshToken()); // get cluster health with token @@ -233,12 +234,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testRefreshingInvalidatedToken() { Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse createTokenResponse = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); assertNotNull(createTokenResponse.getRefreshToken()); InvalidateTokenResponse invalidateResponse = securityClient @@ -257,12 +258,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testRefreshingMultipleTimes() { Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse createTokenResponse = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); assertNotNull(createTokenResponse.getRefreshToken()); CreateTokenResponse refreshResponse = securityClient.prepareRefreshToken(createTokenResponse.getRefreshToken()).get(); @@ -278,12 +279,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testRefreshAsDifferentUser() { Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse createTokenResponse = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); assertNotNull(createTokenResponse.getRefreshToken()); @@ -291,7 +292,7 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { () -> new SecurityClient(client() .filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_SUPERUSER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)))) + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)))) .prepareRefreshToken(createTokenResponse.getRefreshToken()).get()); assertEquals("invalid_grant", e.getMessage()); assertEquals(RestStatus.BAD_REQUEST, e.status()); @@ -301,12 +302,12 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { public void testCreateThenRefreshAsDifferentUser() { Client client = client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_SUPERUSER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); SecurityClient securityClient = new SecurityClient(client); CreateTokenResponse createTokenResponse = securityClient.prepareCreateToken() .setGrantType("password") .setUsername(SecuritySettingsSource.TEST_USER_NAME) - .setPassword(new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())) + .setPassword(new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())) .get(); assertNotNull(createTokenResponse.getRefreshToken()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/UserTokenTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/UserTokenTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/UserTokenTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/UserTokenTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java index a175a0f9b70..753c24beb7d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeRealmMigrateToolTests.java @@ -11,14 +11,13 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.cli.Command; import org.elasticsearch.cli.CommandTestCase; import org.elasticsearch.cli.MockTerminal; -import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.Terminal.Verbosity; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authz.RoleDescriptor; import java.io.FileNotFoundException; @@ -124,7 +123,7 @@ public class ESNativeRealmMigrateToolTests extends CommandTestCase { ESNativeRealmMigrateTool.MigrateUserOrRoles muor = new ESNativeRealmMigrateTool.MigrateUserOrRoles(); - OptionSet options = muor.getParser().parse("-u", "elastic", "-p", SecuritySettingsSource.TEST_PASSWORD, + OptionSet options = muor.getParser().parse("-u", "elastic", "-p", SecuritySettingsSourceField.TEST_PASSWORD, "-U", "http://localhost:9200"); Settings settings = Settings.builder().put("path.home", homeDir).build(); Environment environment = new Environment(settings, confDir); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index 8f1a1f09171..5189ff87d09 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.SecurityLifecycleService; import org.elasticsearch.xpack.security.action.role.DeleteRoleResponse; import org.elasticsearch.xpack.security.action.role.GetRolesResponse; @@ -417,9 +418,9 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { assertThat(client.prepareGetUsers("joes").get().hasUsers(), is(false)); // create joe with a password and verify the user works - client.preparePutUser("joe", SecuritySettingsSource.TEST_PASSWORD.toCharArray(), "admin_role").get(); + client.preparePutUser("joe", SecuritySettingsSourceField.TEST_PASSWORD.toCharArray(), "admin_role").get(); assertThat(client.prepareGetUsers("joe").get().hasUsers(), is(true)); - final String token = basicAuthHeaderValue("joe", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + final String token = basicAuthHeaderValue("joe", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); ClusterHealthResponse response = client().filterWithHeader(Collections.singletonMap("Authorization", token)).admin().cluster() .prepareHealth().get(); assertFalse(response.isTimedOut()); @@ -445,7 +446,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { } // update the user with password and admin role again - String secondPassword = SecuritySettingsSource.TEST_PASSWORD + "2"; + String secondPassword = SecuritySettingsSourceField.TEST_PASSWORD + "2"; client.preparePutUser("joe", secondPassword.toCharArray(), "admin_role").fullName("Joe Smith").get(); getUsersResponse = client.prepareGetUsers("joe").get(); assertThat(getUsersResponse.hasUsers(), is(true)); @@ -513,7 +514,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { public void testOperationsOnReservedUsers() throws Exception { final String username = randomFrom(ElasticUser.NAME, KibanaUser.NAME); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, - () -> securityClient().preparePutUser(username, randomBoolean() ? SecuritySettingsSource.TEST_PASSWORD.toCharArray() + () -> securityClient().preparePutUser(username, randomBoolean() ? SecuritySettingsSourceField.TEST_PASSWORD.toCharArray() : null, "admin").get()); assertThat(exception.getMessage(), containsString("Username [" + username + "] is reserved")); @@ -584,7 +585,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { ChangePasswordResponse passwordResponse = securityClient( client().filterWithHeader(Collections.singletonMap("Authorization", token))) - .prepareChangePassword("joe", SecuritySettingsSource.TEST_PASSWORD.toCharArray()) + .prepareChangePassword("joe", SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()) .get(); assertThat(passwordResponse, notNullValue()); @@ -596,7 +597,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { response = client() .filterWithHeader( Collections.singletonMap("Authorization", - basicAuthHeaderValue("joe", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))) + basicAuthHeaderValue("joe", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))) .admin().cluster().prepareHealth().get(); assertThat(response.isTimedOut(), is(false)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordToolTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileRealmTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileRealmTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java index 409278f3f64..22b3f1f664e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserPasswdStoreTests.java @@ -28,7 +28,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.audit.logfile.CapturingLogger; import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.RealmConfig; @@ -66,7 +66,7 @@ public class FileUserPasswdStoreTests extends ESTestCase { } public void testStore_ConfiguredWithUnreadableFile() throws Exception { - Path xpackConf = env.configFile().resolve(XpackField.NAME); + Path xpackConf = env.configFile().resolve(XPackField.NAME); Files.createDirectories(xpackConf); Path file = xpackConf.resolve("users"); @@ -82,7 +82,7 @@ public class FileUserPasswdStoreTests extends ESTestCase { public void testStore_AutoReload() throws Exception { Path users = getDataPath("users"); - Path xpackConf = env.configFile().resolve(XpackField.NAME); + Path xpackConf = env.configFile().resolve(XPackField.NAME); Files.createDirectories(xpackConf); Path file = xpackConf.resolve("users"); Files.copy(users, file, StandardCopyOption.REPLACE_EXISTING); @@ -119,7 +119,7 @@ public class FileUserPasswdStoreTests extends ESTestCase { public void testStore_AutoReload_WithParseFailures() throws Exception { Path users = getDataPath("users"); - Path xpackConf = env.configFile().resolve(XpackField.NAME); + Path xpackConf = env.configFile().resolve(XPackField.NAME); Files.createDirectories(xpackConf); Path testUsers = xpackConf.resolve("users"); Files.copy(users, testUsers, StandardCopyOption.REPLACE_EXISTING); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java index 493b2c031e0..abac74a1b9e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStoreTests.java @@ -17,7 +17,7 @@ import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.audit.logfile.CapturingLogger; import org.elasticsearch.xpack.security.authc.RealmConfig; import org.junit.After; @@ -270,7 +270,7 @@ public class FileUserRolesStoreTests extends ESTestCase { } private Path getUsersRolesPath() throws IOException { - Path xpackConf = env.configFile().resolve(XpackField.NAME); + Path xpackConf = env.configFile().resolve(XPackField.NAME); Files.createDirectories(xpackConf); return xpackConf.resolve("users_roles"); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java similarity index 89% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java index ce346bdfab2..ac0f8167fad 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractActiveDirectoryIntegTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.junit.annotations.Network; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.VerificationMode; import org.junit.Before; @@ -70,14 +71,14 @@ public class AbstractActiveDirectoryIntegTests extends ESTestCase { Settings buildAdSettings(String ldapUrl, String adDomainName, String userSearchDN, LdapSearchScope scope, boolean hostnameVerification) { Settings.Builder builder = Settings.builder() - .putList(ActiveDirectorySessionFactory.URLS_SETTING, ldapUrl) - .put(ActiveDirectorySessionFactory.AD_DOMAIN_NAME_SETTING, adDomainName) - .put(ActiveDirectorySessionFactory.AD_USER_SEARCH_BASEDN_SETTING, userSearchDN) - .put(ActiveDirectorySessionFactory.AD_USER_SEARCH_SCOPE_SETTING, scope); + .putList(SessionFactorySettings.URLS_SETTING, ldapUrl) + .put(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING, adDomainName) + .put(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_BASEDN_SETTING, userSearchDN) + .put(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_SCOPE_SETTING, scope); if (randomBoolean()) { builder.put("ssl.verification_mode", hostnameVerification ? VerificationMode.FULL : VerificationMode.CERTIFICATE); } else { - builder.put(ActiveDirectorySessionFactory.HOSTNAME_VERIFICATION_SETTING, hostnameVerification); + builder.put(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, hostnameVerification); } if (useGlobalSSL == false) { builder.put("ssl.truststore.path", getDataPath("../ldap/support/ldaptrust.jks")) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java similarity index 89% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java index 2d6d4246d9c..ca27c452655 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryRealmTests.java @@ -11,7 +11,6 @@ import com.unboundid.ldap.sdk.Attribute; import com.unboundid.ldap.sdk.LDAPException; import com.unboundid.ldap.sdk.LDAPURL; import com.unboundid.ldap.sdk.schema.Schema; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.Strings; @@ -19,18 +18,19 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.xpack.security.authc.AuthenticationResult; -import org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.DownLevelADAuthenticator; -import org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.UpnADAuthenticator; -import org.elasticsearch.xpack.security.user.User; -import org.elasticsearch.xpack.security.authc.RealmConfig; -import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm; -import org.elasticsearch.xpack.security.authc.support.DnRoleMapper; -import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; +import org.elasticsearch.xpack.security.authc.AuthenticationResult; +import org.elasticsearch.xpack.security.authc.RealmConfig; +import org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.DownLevelADAuthenticator; +import org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactory.UpnADAuthenticator; +import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealmSettings; +import org.elasticsearch.xpack.security.authc.support.DnRoleMapper; +import org.elasticsearch.xpack.security.authc.support.DnRoleMapperSettings; +import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; +import org.elasticsearch.xpack.security.user.User; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.VerificationMode; import org.junit.After; @@ -43,8 +43,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.HOSTNAME_VERIFICATION_SETTING; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.URLS_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.URLS_SETTING; import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.arrayContainingInAnyOrder; import static org.hamcrest.Matchers.containsString; @@ -72,7 +72,7 @@ import static org.mockito.Mockito.verify; public class ActiveDirectoryRealmTests extends ESTestCase { private static final String PASSWORD = "password"; - private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapper.ROLE_MAPPING_FILE_SETTING.getKey(); + private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.getKey(); static int numberOfLdapServers; InMemoryDirectoryServer[] directoryServers; @@ -136,7 +136,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testAuthenticateUserPrincipleName", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); PlainActionFuture future = new PlainActionFuture<>(); realm.authenticate(new UsernamePasswordToken("CN=ironman", new SecureString(PASSWORD)), future); @@ -152,7 +152,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testAuthenticateSAMAccountName", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); // Thor does not have a UPN of form CN=Thor@ad.test.elasticsearch.com PlainActionFuture future = new PlainActionFuture<>(); @@ -176,7 +176,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testAuthenticateCachesSuccesfulAuthentications", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = spy(new ActiveDirectorySessionFactory(config, sslService, threadPool)); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); int count = randomIntBetween(2, 10); for (int i = 0; i < count; i++) { @@ -190,11 +190,11 @@ public class ActiveDirectoryRealmTests extends ESTestCase { } public void testAuthenticateCachingCanBeDisabled() throws Exception { - Settings settings = settings(Settings.builder().put(CachingUsernamePasswordRealm.CACHE_TTL_SETTING.getKey(), -1).build()); + Settings settings = settings(Settings.builder().put(CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.getKey(), -1).build()); RealmConfig config = new RealmConfig("testAuthenticateCachingCanBeDisabled", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = spy(new ActiveDirectorySessionFactory(config, sslService, threadPool)); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); int count = randomIntBetween(2, 10); for (int i = 0; i < count; i++) { @@ -212,7 +212,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testAuthenticateCachingClearsCacheOnRoleMapperRefresh", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = spy(new ActiveDirectorySessionFactory(config, sslService, threadPool)); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); int count = randomIntBetween(2, 10); for (int i = 0; i < count; i++) { @@ -246,15 +246,15 @@ public class ActiveDirectoryRealmTests extends ESTestCase { private void doUnauthenticatedLookup(boolean pooled) throws Exception { Settings settings = settings(Settings.builder() - .put(ActiveDirectorySessionFactory.POOL_ENABLED.getKey(), pooled) - .put(ActiveDirectorySessionFactory.BIND_DN.getKey(), "CN=ironman@ad.test.elasticsearch.com") - .put(ActiveDirectorySessionFactory.BIND_PASSWORD.getKey(), PASSWORD) + .put(ActiveDirectorySessionFactorySettings.POOL_ENABLED.getKey(), pooled) + .put(PoolingSessionFactorySettings.BIND_DN.getKey(), "CN=ironman@ad.test.elasticsearch.com") + .put(PoolingSessionFactorySettings.BIND_PASSWORD.getKey(), PASSWORD) .build()); RealmConfig config = new RealmConfig("testUnauthenticatedLookupWithConnectionPool", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); try (ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool)) { DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); PlainActionFuture future = new PlainActionFuture<>(); realm.lookupUser("CN=Thor", future); @@ -271,7 +271,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testRealmMapsGroupsToRoles", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); PlainActionFuture future = new PlainActionFuture<>(); realm.authenticate(new UsernamePasswordToken("CN=ironman", new SecureString(PASSWORD)), future); @@ -287,7 +287,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { RealmConfig config = new RealmConfig("testRealmMapsGroupsToRoles", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); PlainActionFuture future = new PlainActionFuture<>(); realm.authenticate(new UsernamePasswordToken("CN=Thor", new SecureString(PASSWORD)), future); @@ -306,7 +306,7 @@ public class ActiveDirectoryRealmTests extends ESTestCase { new ThreadContext(globalSettings)); ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = new DnRoleMapper(config, resourceWatcherService); - LdapRealm realm = new LdapRealm(LdapRealm.AD_TYPE, config, sessionFactory, roleMapper, threadPool); + LdapRealm realm = new LdapRealm(LdapRealmSettings.AD_TYPE, config, sessionFactory, roleMapper, threadPool); Map stats = realm.usageStats(); assertThat(stats, is(notNullValue())); @@ -330,9 +330,9 @@ public class ActiveDirectoryRealmTests extends ESTestCase { public void testCustomSearchFilters() throws Exception { Settings settings = settings(Settings.builder() - .put(ActiveDirectorySessionFactory.AD_USER_SEARCH_FILTER_SETTING, "(objectClass=default)") - .put(ActiveDirectorySessionFactory.AD_UPN_USER_SEARCH_FILTER_SETTING, "(objectClass=upn)") - .put(ActiveDirectorySessionFactory.AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING, "(objectClass=down level)") + .put(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_FILTER_SETTING, "(objectClass=default)") + .put(ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING, "(objectClass=upn)") + .put(ActiveDirectorySessionFactorySettings.AD_DOWN_LEVEL_USER_SEARCH_FILTER_SETTING, "(objectClass=down level)") .build()); RealmConfig config = new RealmConfig("testDefaultSearchFilters", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); @@ -349,8 +349,8 @@ public class ActiveDirectoryRealmTests extends ESTestCase { private Settings settings(Settings extraSettings) throws Exception { Settings.Builder builder = Settings.builder() .putList(URLS_SETTING, ldapUrls()) - .put(ActiveDirectorySessionFactory.AD_DOMAIN_NAME_SETTING, "ad.test.elasticsearch.com") - .put(DnRoleMapper.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(), true); + .put(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING, "ad.test.elasticsearch.com") + .put(DnRoleMapperSettings.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(), true); if (randomBoolean()) { builder.put("ssl.verification_mode", VerificationMode.CERTIFICATE); } else { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java index a51660a6695..9631641f4d5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java @@ -21,6 +21,7 @@ import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.test.junit.annotations.Network; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.VerificationMode; import org.junit.After; @@ -113,7 +114,7 @@ public class ActiveDirectorySessionFactoryTests extends AbstractActiveDirectoryI .put(buildAdSettings(AD_LDAP_URL, AD_DOMAIN, false)) .put("group_search.filter", "(objectClass=*)") .put("ssl.verification_mode", VerificationMode.CERTIFICATE) - .put(SessionFactory.TIMEOUT_TCP_READ_SETTING, "1ms") + .put(SessionFactorySettings.TIMEOUT_TCP_READ_SETTING, "1ms") .build(); RealmConfig config = new RealmConfig("ad-test", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); @@ -195,9 +196,9 @@ public class ActiveDirectorySessionFactoryTests extends AbstractActiveDirectoryI Settings settings = Settings.builder() .put(buildAdSettings(AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com", LdapSearchScope.ONE_LEVEL, false)) - .put(ActiveDirectorySessionFactory.AD_GROUP_SEARCH_BASEDN_SETTING, + .put(ActiveDirectorySessionFactorySettings.AD_GROUP_SEARCH_BASEDN_SETTING, "CN=Avengers,CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com") - .put(ActiveDirectorySessionFactory.AD_GROUP_SEARCH_SCOPE_SETTING, LdapSearchScope.BASE) + .put(ActiveDirectorySessionFactorySettings.AD_GROUP_SEARCH_SCOPE_SETTING, LdapSearchScope.BASE) .build(); RealmConfig config = new RealmConfig("ad-test", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); @@ -262,7 +263,7 @@ public class ActiveDirectorySessionFactoryTests extends AbstractActiveDirectoryI Settings settings = Settings.builder() .put(buildAdSettings(AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com", LdapSearchScope.SUB_TREE, false)) - .put(ActiveDirectorySessionFactory.AD_USER_SEARCH_FILTER_SETTING, + .put(ActiveDirectorySessionFactorySettings.AD_USER_SEARCH_FILTER_SETTING, "(&(objectclass=user)(userPrincipalName={0}@ad.test.elasticsearch.com))") .build(); RealmConfig config = @@ -445,12 +446,12 @@ public class ActiveDirectorySessionFactoryTests extends AbstractActiveDirectoryI private Settings buildAdSettings(String ldapUrl, String adDomainName, boolean hostnameVerification, boolean useBindUser) { Settings.Builder builder = Settings.builder() - .put(ActiveDirectorySessionFactory.URLS_SETTING, ldapUrl) - .put(ActiveDirectorySessionFactory.AD_DOMAIN_NAME_SETTING, adDomainName); + .put(SessionFactorySettings.URLS_SETTING, ldapUrl) + .put(ActiveDirectorySessionFactorySettings.AD_DOMAIN_NAME_SETTING, adDomainName); if (randomBoolean()) { builder.put("ssl.verification_mode", hostnameVerification ? VerificationMode.FULL : VerificationMode.CERTIFICATE); } else { - builder.put(ActiveDirectorySessionFactory.HOSTNAME_VERIFICATION_SETTING, hostnameVerification); + builder.put(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, hostnameVerification); } if (useGlobalSSL == false) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/CancellableLdapRunnableTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/CancellableLdapRunnableTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/CancellableLdapRunnableTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/CancellableLdapRunnableTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/GroupsResolverTestCase.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/GroupsResolverTestCase.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/GroupsResolverTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/GroupsResolverTestCase.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java index 9c1e697aeaa..8163dc1803b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapRealmTests.java @@ -20,8 +20,9 @@ import org.elasticsearch.xpack.security.authc.RealmConfig; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.xpack.security.authc.ldap.support.LdapTestCase; import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; -import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm; +import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealmSettings; import org.elasticsearch.xpack.security.authc.support.DnRoleMapper; +import org.elasticsearch.xpack.security.authc.support.DnRoleMapperSettings; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.user.User; import org.elasticsearch.xpack.ssl.SSLService; @@ -33,7 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory.URLS_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.URLS_SETTING; import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; @@ -55,7 +56,7 @@ public class LdapRealmTests extends LdapTestCase { public static final String VALID_USERNAME = "Thomas Masterman Hardy"; public static final String PASSWORD = "pass"; - private static final String USER_DN_TEMPLATES_SETTING_KEY = LdapSessionFactory.USER_DN_TEMPLATES_SETTING.getKey(); + private static final String USER_DN_TEMPLATES_SETTING_KEY = LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING.getKey(); private ThreadPool threadPool; private ResourceWatcherService resourceWatcherService; @@ -82,7 +83,7 @@ public class LdapRealmTests extends LdapTestCase { Settings settings = buildLdapSettings(ldapUrls(), userTemplate, groupSearchBase, LdapSearchScope.SUB_TREE); RealmConfig config = new RealmConfig("test-ldap-realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); - LdapRealm ldap = new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), + LdapRealm ldap = new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); @@ -108,7 +109,7 @@ public class LdapRealmTests extends LdapTestCase { LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); LdapRealm ldap = - new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); + new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); ldap.authenticate(new UsernamePasswordToken(VALID_USERNAME, new SecureString(PASSWORD)), future); @@ -134,7 +135,7 @@ public class LdapRealmTests extends LdapTestCase { LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); ldapFactory = spy(ldapFactory); LdapRealm ldap = - new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); + new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); ldap.authenticate(new UsernamePasswordToken(VALID_USERNAME, new SecureString(PASSWORD)), future); @@ -159,7 +160,7 @@ public class LdapRealmTests extends LdapTestCase { LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); DnRoleMapper roleMapper = buildGroupAsRoleMapper(resourceWatcherService); ldapFactory = spy(ldapFactory); - LdapRealm ldap = new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, roleMapper, threadPool); + LdapRealm ldap = new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, roleMapper, threadPool); PlainActionFuture future = new PlainActionFuture<>(); ldap.authenticate(new UsernamePasswordToken(VALID_USERNAME, new SecureString(PASSWORD)), future); future.actionGet(); @@ -185,14 +186,14 @@ public class LdapRealmTests extends LdapTestCase { String userTemplate = VALID_USER_TEMPLATE; Settings settings = Settings.builder() .put(buildLdapSettings(ldapUrls(), userTemplate, groupSearchBase, LdapSearchScope.SUB_TREE)) - .put(CachingUsernamePasswordRealm.CACHE_TTL_SETTING.getKey(), -1) + .put(CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.getKey(), -1) .build(); RealmConfig config = new RealmConfig("test-ldap-realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); ldapFactory = spy(ldapFactory); LdapRealm ldap = - new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); + new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); ldap.authenticate(new UsernamePasswordToken(VALID_USERNAME, new SecureString(PASSWORD)), future); future.actionGet(); @@ -215,7 +216,7 @@ public class LdapRealmTests extends LdapTestCase { .put("ssl.verification_mode", VerificationMode.CERTIFICATE) .build(); RealmConfig config = new RealmConfig("test-ldap-realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); - SessionFactory sessionFactory = LdapRealm.sessionFactory(config, sslService, threadPool, LdapRealm.LDAP_TYPE); + SessionFactory sessionFactory = LdapRealm.sessionFactory(config, sslService, threadPool, LdapRealmSettings.LDAP_TYPE); assertThat(sessionFactory, is(instanceOf(LdapSessionFactory.class))); } @@ -231,7 +232,7 @@ public class LdapRealmTests extends LdapTestCase { .put("ssl.verification_mode", VerificationMode.CERTIFICATE) .build(); RealmConfig config = new RealmConfig("test-ldap-realm-user-search", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); - SessionFactory sessionFactory = LdapRealm.sessionFactory(config, sslService, threadPool, LdapRealm.LDAP_TYPE); + SessionFactory sessionFactory = LdapRealm.sessionFactory(config, sslService, threadPool, LdapRealmSettings.LDAP_TYPE); try { assertThat(sessionFactory, is(instanceOf(LdapUserSearchSessionFactory.class))); } finally { @@ -250,7 +251,7 @@ public class LdapRealmTests extends LdapTestCase { .build(); RealmConfig config = new RealmConfig("test-ldap-realm-user-search", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> LdapRealm.sessionFactory(config, null, threadPool, LdapRealm.LDAP_TYPE)); + () -> LdapRealm.sessionFactory(config, null, threadPool, LdapRealmSettings.LDAP_TYPE)); assertThat(e.getMessage(), containsString("settings were found for both" + " user search [xpack.security.authc.realms.test-ldap-realm-user-search.user_search.] and" + @@ -266,7 +267,7 @@ public class LdapRealmTests extends LdapTestCase { .build(); RealmConfig config = new RealmConfig("test-ldap-realm-user-search", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> LdapRealm.sessionFactory(config, null, threadPool, LdapRealm.LDAP_TYPE)); + () -> LdapRealm.sessionFactory(config, null, threadPool, LdapRealmSettings.LDAP_TYPE)); assertThat(e.getMessage(), containsString("settings were not found for either" + " user search [xpack.security.authc.realms.test-ldap-realm-user-search.user_search.] or" + @@ -278,13 +279,13 @@ public class LdapRealmTests extends LdapTestCase { String userTemplate = VALID_USER_TEMPLATE; Settings settings = Settings.builder() .put(buildLdapSettings(ldapUrls(), userTemplate, groupSearchBase, LdapSearchScope.SUB_TREE)) - .put(DnRoleMapper.ROLE_MAPPING_FILE_SETTING.getKey(), + .put(DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.getKey(), getDataPath("/org/elasticsearch/xpack/security/authc/support/role_mapping.yml")) .build(); RealmConfig config = new RealmConfig("test-ldap-realm-userdn", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); - LdapRealm ldap = new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, + LdapRealm ldap = new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, new DnRoleMapper(config, resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); @@ -310,7 +311,7 @@ public class LdapRealmTests extends LdapTestCase { Settings settings = buildLdapSettings(new String[] { url.toString() }, userTemplate, groupSearchBase, LdapSearchScope.SUB_TREE); RealmConfig config = new RealmConfig("test-ldap-realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); - LdapRealm ldap = new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), + LdapRealm ldap = new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, buildGroupAsRoleMapper(resourceWatcherService), threadPool); PlainActionFuture future = new PlainActionFuture<>(); @@ -331,7 +332,7 @@ public class LdapRealmTests extends LdapTestCase { .put("bind_password", PASSWORD) .put("group_search.base_dn", groupSearchBase) .put("group_search.scope", LdapSearchScope.SUB_TREE) - .put(LdapSessionFactory.USER_DN_TEMPLATES_SETTING.getKey(), "--") + .put(LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING.getKey(), "--") .put("ssl.verification_mode", VerificationMode.CERTIFICATE); int order = randomIntBetween(0, 10); @@ -345,7 +346,7 @@ public class LdapRealmTests extends LdapTestCase { RealmConfig config = new RealmConfig("ldap-realm", settings.build(), globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); LdapSessionFactory ldapFactory = new LdapSessionFactory(config, sslService, threadPool); - LdapRealm realm = new LdapRealm(LdapRealm.LDAP_TYPE, config, ldapFactory, + LdapRealm realm = new LdapRealm(LdapRealmSettings.LDAP_TYPE, config, ldapFactory, new DnRoleMapper(config, resourceWatcherService), threadPool); Map stats = realm.usageStats(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java index 7a97b23866a..64945b870f6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapSessionFactoryTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; import org.elasticsearch.test.junit.annotations.Network; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.junit.After; import org.junit.Before; @@ -61,7 +62,7 @@ public class LdapSessionFactoryTests extends LdapTestCase { Settings settings = Settings.builder() .put(buildLdapSettings(ldapUrl, userTemplates, groupSearchBase, LdapSearchScope.SUB_TREE)) - .put(SessionFactory.TIMEOUT_TCP_READ_SETTING, "1ms") //1 millisecond + .put(SessionFactorySettings.TIMEOUT_TCP_READ_SETTING, "1ms") //1 millisecond .put("path.home", createTempDir()) .build(); @@ -92,7 +93,7 @@ public class LdapSessionFactoryTests extends LdapTestCase { Settings settings = Settings.builder() .put(buildLdapSettings(ldapUrl, userTemplates, groupSearchBase, LdapSearchScope.SUB_TREE)) - .put(SessionFactory.TIMEOUT_TCP_CONNECTION_SETTING, "1ms") //1 millisecond + .put(SessionFactorySettings.TIMEOUT_TCP_CONNECTION_SETTING, "1ms") //1 millisecond .build(); RealmConfig config = new RealmConfig("ldap_realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java index d3f868e0324..95ca0f33e06 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java @@ -18,6 +18,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils; import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.VerificationMode; @@ -56,8 +57,8 @@ public class LdapTestUtils { LDAPConnectionOptions options = new LDAPConnectionOptions(); options.setFollowReferrals(true); options.setAllowConcurrentSocketFactoryUse(true); - options.setConnectTimeoutMillis(Math.toIntExact(SessionFactory.TIMEOUT_DEFAULT.millis())); - options.setResponseTimeoutMillis(SessionFactory.TIMEOUT_DEFAULT.millis()); + options.setConnectTimeoutMillis(Math.toIntExact(SessionFactorySettings.TIMEOUT_DEFAULT.millis())); + options.setResponseTimeoutMillis(SessionFactorySettings.TIMEOUT_DEFAULT.millis()); Settings connectionSettings; if (useGlobalSSL) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java index dbfda854a58..7f07edd68b6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapUserSearchSessionFactoryTests.java @@ -28,6 +28,7 @@ import org.elasticsearch.xpack.security.authc.RealmConfig; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; import org.elasticsearch.xpack.security.authc.ldap.support.LdapTestCase; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.security.support.NoOpLogger; import org.elasticsearch.test.junit.annotations.Network; @@ -106,7 +107,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -154,7 +155,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -191,7 +192,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -239,7 +240,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -276,7 +277,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -324,7 +325,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -360,7 +361,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } if (useAttribute) { - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } } @@ -472,13 +473,13 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { () -> "cn=Horatio Hornblower,ou=people,o=sevenSeas"); try { assertThat(connectionPool.getCurrentAvailableConnections(), - is(LdapUserSearchSessionFactory.DEFAULT_CONNECTION_POOL_INITIAL_SIZE)); + is(PoolingSessionFactorySettings.DEFAULT_CONNECTION_POOL_INITIAL_SIZE)); assertThat(connectionPool.getMaximumAvailableConnections(), - is(LdapUserSearchSessionFactory.DEFAULT_CONNECTION_POOL_SIZE)); + is(PoolingSessionFactorySettings.DEFAULT_CONNECTION_POOL_SIZE)); assertEquals(connectionPool.getHealthCheck().getClass(), GetEntryLDAPConnectionPoolHealthCheck.class); GetEntryLDAPConnectionPoolHealthCheck healthCheck = (GetEntryLDAPConnectionPoolHealthCheck) connectionPool.getHealthCheck(); assertThat(healthCheck.getEntryDN(), is("cn=Horatio Hornblower,ou=people,o=sevenSeas")); - assertThat(healthCheck.getMaxResponseTimeMillis(), is(LdapUserSearchSessionFactory.TIMEOUT_DEFAULT.millis())); + assertThat(healthCheck.getMaxResponseTimeMillis(), is(SessionFactorySettings.TIMEOUT_DEFAULT.millis())); } finally { connectionPool.close(); } @@ -601,7 +602,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase { } } - assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactory.SEARCH_ATTRIBUTE }); + assertSettingDeprecationsAndWarnings(new Setting[] { LdapUserSearchSessionFactorySettings.SEARCH_ATTRIBUTE }); } static LdapUserSearchSessionFactory getLdapUserSearchSessionFactory(RealmConfig config, SSLService sslService, ThreadPool threadPool) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverInMemoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverInMemoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverInMemoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverInMemoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LDAPServersTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LDAPServersTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LDAPServersTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LDAPServersTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java similarity index 83% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java index cd7fd3abeb3..66c825f82f5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapLoadBalancingTests.java @@ -20,8 +20,8 @@ public class LdapLoadBalancingTests extends ESTestCase { public void testBadTypeThrowsException() { String badType = randomAlphaOfLengthBetween(3, 12); - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, badType).build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, badType).build(); try { LdapLoadBalancing.serverSet(null, null, settings, null, null); fail("using type [" + badType + "] should have thrown an exception"); @@ -31,8 +31,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testFailoverServerSet() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "failover").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "failover").build(); String[] address = new String[] { "localhost" }; int[] ports = new int[] { 26000 }; ServerSet serverSet = LdapLoadBalancing.serverSet(address, ports, settings, null, null); @@ -41,8 +41,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testDnsFailover() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "dns_failover").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "dns_failover").build(); String[] address = new String[] { "foo.bar" }; int[] ports = new int[] { 26000 }; ServerSet serverSet = LdapLoadBalancing.serverSet(address, ports, settings, null, null); @@ -51,8 +51,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testDnsFailoverBadArgs() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "dns_failover").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "dns_failover").build(); String[] addresses = new String[] { "foo.bar", "localhost" }; int[] ports = new int[] { 26000, 389 }; try { @@ -71,8 +71,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testRoundRobin() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "round_robin").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "round_robin").build(); String[] address = new String[] { "localhost", "foo.bar" }; int[] ports = new int[] { 389, 389 }; ServerSet serverSet = LdapLoadBalancing.serverSet(address, ports, settings, null, null); @@ -80,8 +80,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testDnsRoundRobin() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "dns_round_robin").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "dns_round_robin").build(); String[] address = new String[] { "foo.bar" }; int[] ports = new int[] { 26000 }; ServerSet serverSet = LdapLoadBalancing.serverSet(address, ports, settings, null, null); @@ -91,8 +91,8 @@ public class LdapLoadBalancingTests extends ESTestCase { } public void testDnsRoundRobinBadArgs() { - Settings settings = Settings.builder().put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, "dns_round_robin").build(); + Settings settings = Settings.builder().put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, "dns_round_robin").build(); String[] addresses = new String[] { "foo.bar", "localhost" }; int[] ports = new int[] { 26000, 389 }; try { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapMetaDataResolverTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java similarity index 90% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java index c913ab91506..77041cc3e7e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/LdapTestCase.java @@ -12,8 +12,6 @@ import com.unboundid.ldap.sdk.LDAPConnectionPool; import com.unboundid.ldap.sdk.LDAPException; import com.unboundid.ldap.sdk.LDAPInterface; import com.unboundid.ldap.sdk.LDAPURL; - -import org.elasticsearch.SpecialPermission; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; @@ -21,11 +19,12 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.xpack.security.authc.RealmConfig; -import org.elasticsearch.xpack.security.authc.ldap.LdapSessionFactory; -import org.elasticsearch.xpack.security.authc.support.DnRoleMapper; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.watcher.ResourceWatcherService; +import org.elasticsearch.xpack.security.authc.RealmConfig; +import org.elasticsearch.xpack.security.authc.ldap.LdapSessionFactorySettings; +import org.elasticsearch.xpack.security.authc.support.DnRoleMapper; +import org.elasticsearch.xpack.security.authc.support.DnRoleMapperSettings; import org.elasticsearch.xpack.ssl.VerificationMode; import org.junit.After; import org.junit.Before; @@ -33,18 +32,17 @@ import org.junit.BeforeClass; import java.security.AccessController; import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import static org.elasticsearch.xpack.security.authc.ldap.LdapSessionFactory.HOSTNAME_VERIFICATION_SETTING; -import static org.elasticsearch.xpack.security.authc.ldap.LdapSessionFactory.URLS_SETTING; - +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING; +import static org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings.URLS_SETTING; +// public abstract class LdapTestCase extends ESTestCase { - private static final String USER_DN_TEMPLATES_SETTING_KEY = LdapSessionFactory.USER_DN_TEMPLATES_SETTING.getKey(); + private static final String USER_DN_TEMPLATES_SETTING_KEY = LdapSessionFactorySettings.USER_DN_TEMPLATES_SETTING.getKey(); static int numberOfLdapServers; protected InMemoryDirectoryServer[] ldapServers; @@ -114,14 +112,14 @@ public abstract class LdapTestCase extends ESTestCase { Settings.Builder builder = Settings.builder() .putList(URLS_SETTING, ldapUrl) .putList(USER_DN_TEMPLATES_SETTING_KEY, userTemplate) - .put(SessionFactory.TIMEOUT_TCP_CONNECTION_SETTING, TimeValue.timeValueSeconds(1L)) - .put(SessionFactory.IGNORE_REFERRAL_ERRORS_SETTING.getKey(), ignoreReferralErrors) + .put(SessionFactorySettings.TIMEOUT_TCP_CONNECTION_SETTING, TimeValue.timeValueSeconds(1L)) + .put(SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING.getKey(), ignoreReferralErrors) .put("group_search.base_dn", groupSearchBase) .put("group_search.scope", scope) .put("ssl.verification_mode", VerificationMode.CERTIFICATE); if (serverSetType != null) { - builder.put(LdapLoadBalancing.LOAD_BALANCE_SETTINGS + "." + - LdapLoadBalancing.LOAD_BALANCE_TYPE_SETTING, serverSetType.toString()); + builder.put(LdapLoadBalancingSettings.LOAD_BALANCE_SETTINGS + "." + + LdapLoadBalancingSettings.LOAD_BALANCE_TYPE_SETTING, serverSetType.toString()); } return builder.build(); } @@ -140,7 +138,7 @@ public abstract class LdapTestCase extends ESTestCase { protected DnRoleMapper buildGroupAsRoleMapper(ResourceWatcherService resourceWatcherService) { Settings settings = Settings.builder() - .put(DnRoleMapper.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(), true) + .put(DnRoleMapperSettings.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(), true) .build(); Settings global = Settings.builder().put("path.home", createTempDir()).build(); RealmConfig config = new RealmConfig("ldap1", settings, global, TestEnvironment.newEnvironment(global), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryLoadBalancingTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryLoadBalancingTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryLoadBalancingTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryLoadBalancingTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java index 994ed65de43..53c93c4a154 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactoryTests.java @@ -58,10 +58,10 @@ public class SessionFactoryTests extends ESTestCase { public void testConnectionFactoryReturnsCorrectLDAPConnectionOptions() throws Exception { Settings settings = Settings.builder() - .put(SessionFactory.TIMEOUT_TCP_CONNECTION_SETTING, "10ms") - .put(SessionFactory.HOSTNAME_VERIFICATION_SETTING, "false") - .put(SessionFactory.TIMEOUT_TCP_READ_SETTING, "20ms") - .put(SessionFactory.FOLLOW_REFERRALS_SETTING, "false") + .put(SessionFactorySettings.TIMEOUT_TCP_CONNECTION_SETTING, "10ms") + .put(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING, "false") + .put(SessionFactorySettings.TIMEOUT_TCP_READ_SETTING, "20ms") + .put(SessionFactorySettings.FOLLOW_REFERRALS_SETTING, "false") .build(); final Environment environment = TestEnvironment.newEnvironment(Settings.builder().put("path.home", createTempDir()).build()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java index 0628b2376dc..5f28fa1bf24 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiAuthenticationTests.java @@ -25,8 +25,11 @@ import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; import org.elasticsearch.xpack.common.socket.SocketAccess; +import org.elasticsearch.xpack.security.LocalStateSecurity; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; import org.elasticsearch.xpack.ssl.SSLClientAuth; import javax.net.ssl.KeyManagerFactory; @@ -59,9 +62,9 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase { .put(NetworkModule.HTTP_ENABLED.getKey(), true) .put("xpack.security.http.ssl.enabled", true) .put("xpack.security.http.ssl.client_authentication", sslClientAuth) - .put("xpack.security.authc.realms.file.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.file.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.file.order", "0") - .put("xpack.security.authc.realms.pki1.type", PkiRealm.TYPE) + .put("xpack.security.authc.realms.pki1.type", PkiRealmSettings.TYPE) .put("xpack.security.authc.realms.pki1.order", "1") .put("xpack.security.authc.realms.pki1.truststore.path", getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks")) @@ -151,9 +154,9 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase { Settings.Builder builder = Settings.builder().put(clientSettings, false) .put(additionalSettings) .put("cluster.name", internalCluster().getClusterName()); - builder.remove(Security.USER_SETTING.getKey()); + builder.remove(SecurityField.USER_SETTING.getKey()); builder.remove("request.headers.Authorization"); - return new TestXPackTransportClient(builder.build()); + return new TestXPackTransportClient(builder.build(), LocalStateSecurity.class); } private String getNodeUrl() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java index f6f77587c79..7db3b84390b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiOptionalClientAuthTests.java @@ -11,11 +11,11 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; import org.elasticsearch.common.network.NetworkModule; -import org.elasticsearch.common.settings.MockSecureSettings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.ssl.SSLClientAuth; import org.junit.BeforeClass; @@ -83,7 +83,7 @@ public class PkiOptionalClientAuthTests extends SecurityIntegTestCase { Response response = restClient.performRequest("GET", "_nodes", new BasicHeader(UsernamePasswordToken.BASIC_AUTH_HEADER, UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())))); assertThat(response.getStatusLine().getStatusCode(), is(200)); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java index ab4da6cd6a4..c3a5e1bdc1a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/pki/PkiRealmTests.java @@ -236,7 +236,7 @@ public class PkiRealmTests extends ESTestCase { when(certificate.getSubjectX500Principal()).thenReturn(principal); X509AuthenticationToken token = PkiRealm.token(new X509Certificate[] { certificate }, - Pattern.compile(PkiRealm.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); + Pattern.compile(PkiRealmSettings.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); assertThat(token, notNullValue()); assertThat(token.principal(), is("PKI Client")); assertThat(token.dn(), is("CN=PKI Client")); @@ -248,7 +248,7 @@ public class PkiRealmTests extends ESTestCase { when(certificate.getSubjectX500Principal()).thenReturn(principal); X509AuthenticationToken token = PkiRealm.token(new X509Certificate[] { certificate }, - Pattern.compile(PkiRealm.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); + Pattern.compile(PkiRealmSettings.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); assertThat(token, notNullValue()); assertThat(token.principal(), is("PKI Client")); assertThat(token.dn(), is("CN=PKI Client, OU=Security")); @@ -260,7 +260,7 @@ public class PkiRealmTests extends ESTestCase { when(certificate.getSubjectX500Principal()).thenReturn(principal); X509AuthenticationToken token = PkiRealm.token(new X509Certificate[] { certificate }, - Pattern.compile(PkiRealm.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); + Pattern.compile(PkiRealmSettings.DEFAULT_USERNAME_PATTERN), NoOpLogger.INSTANCE); assertThat(token, notNullValue()); assertThat(token.principal(), is("PKI Client")); assertThat(token.dn(), is("EMAILADDRESS=pki@elastic.co, CN=PKI Client, OU=Security")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/BCryptTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java index 774e8399c82..b5f0c51c77b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/CachingUsernamePasswordRealmTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authc.AuthenticationResult; import org.elasticsearch.xpack.security.authc.Realm; import org.elasticsearch.xpack.security.authc.RealmConfig; @@ -51,9 +51,9 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase { int maxUsers = randomIntBetween(10, 100); TimeValue ttl = TimeValue.timeValueMinutes(randomIntBetween(10, 20)); Settings settings = Settings.builder() - .put(CachingUsernamePasswordRealm.CACHE_HASH_ALGO_SETTING.getKey(), hashAlgo) - .put(CachingUsernamePasswordRealm.CACHE_MAX_USERS_SETTING.getKey(), maxUsers) - .put(CachingUsernamePasswordRealm.CACHE_TTL_SETTING.getKey(), ttl) + .put(CachingUsernamePasswordRealmSettings.CACHE_HASH_ALGO_SETTING.getKey(), hashAlgo) + .put(CachingUsernamePasswordRealmSettings.CACHE_MAX_USERS_SETTING.getKey(), maxUsers) + .put(CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.getKey(), ttl) .build(); RealmConfig config = new RealmConfig("test_realm", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), @@ -226,7 +226,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase { public void testCacheWithVeryLowTtlExpiresBetweenAuthenticateCalls() throws InterruptedException { TimeValue ttl = TimeValue.timeValueNanos(randomIntBetween(10, 100)); Settings settings = Settings.builder() - .put(CachingUsernamePasswordRealm.CACHE_TTL_SETTING.getKey(), ttl) + .put(CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.getKey(), ttl) .build(); RealmConfig config = new RealmConfig("test_cache_ttl", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY)); @@ -255,7 +255,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase { public void testReadsDoNotPreventCacheExpiry() throws InterruptedException { TimeValue ttl = TimeValue.timeValueMillis(250); Settings settings = Settings.builder() - .put(CachingUsernamePasswordRealm.CACHE_TTL_SETTING.getKey(), ttl) + .put(CachingUsernamePasswordRealmSettings.CACHE_TTL_SETTING.getKey(), ttl) .build(); RealmConfig config = new RealmConfig("test_cache_ttl", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY)); @@ -330,7 +330,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase { public void testCacheConcurrency() throws Exception { final String username = "username"; - final SecureString password = SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING; + final SecureString password = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING; final SecureString randomPassword = new SecureString(randomAlphaOfLength(password.length()).toCharArray()); final String passwordHash = new String(Hasher.BCRYPT.hash(password)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java index 54cef5b63fe..afcf0781cc5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/DnRoleMapperTests.java @@ -50,8 +50,9 @@ import static org.hamcrest.Matchers.notNullValue; public class DnRoleMapperTests extends ESTestCase { - private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapper.ROLE_MAPPING_FILE_SETTING.getKey(); - private static final String USE_UNMAPPED_GROUPS_AS_ROLES_SETTING_KEY = DnRoleMapper.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(); + private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.getKey(); + private static final String USE_UNMAPPED_GROUPS_AS_ROLES_SETTING_KEY = + DnRoleMapperSettings.USE_UNMAPPED_GROUPS_AS_ROLES_SETTING.getKey(); private static final String[] STARK_GROUP_DNS = new String[] { //groups can be named by different attributes, depending on the directory, @@ -179,7 +180,8 @@ public class DnRoleMapperTests extends ESTestCase { } assertBusy(() -> { - Set resolvedRoles = mapper.resolveRoles("", Collections.singletonList("cn=fantastic_four,ou=marvel,o=superheros")); + Set resolvedRoles = mapper.resolveRoles("", + Collections.singletonList("cn=fantastic_four,ou=marvel,o=superheros")); assertThat(resolvedRoles, notNullValue()); assertThat(resolvedRoles.size(), is(1)); assertThat(resolvedRoles, contains("fantastic_four")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/HasherTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java index c0893e8983e..8d4fa3066b6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/RoleMappingFileBootstrapCheckTests.java @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.notNullValue; public class RoleMappingFileBootstrapCheckTests extends ESTestCase { - private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapper.ROLE_MAPPING_FILE_SETTING.getKey(); + private static final String ROLE_MAPPING_FILE_SETTING = DnRoleMapperSettings.ROLE_MAPPING_FILE_SETTING.getKey(); protected Settings settings; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordTokenTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordTokenTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordTokenTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/UsernamePasswordTokenTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeUserRoleMapperTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeUserRoleMapperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeUserRoleMapperTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeUserRoleMapperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java index 4bdd4f80707..b67beb7ac9a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/ExpressionParserTests.java @@ -17,11 +17,13 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource; @@ -121,7 +123,7 @@ public class ExpressionParserTests extends ESTestCase { assertThat(json(expr), equalTo(json.replaceAll("\\s", ""))); } - public void testWriteAndReadFromStream() throws IOException { + public void testWriteAndReadFromStream() throws Exception { String json = "{ \"any\": [" + " { \"field\": { \"username\" : \"*@shield.gov\" } }, " + " { \"all\": [" + @@ -136,7 +138,8 @@ public class ExpressionParserTests extends ESTestCase { final BytesStreamOutput out = new BytesStreamOutput(); ExpressionParser.writeExpression(exprSource, out); - final NamedWriteableRegistry registry = new NamedWriteableRegistry(Security.getNamedWriteables()); + final Settings settings = Settings.builder().put("path.home", createTempDir()).build(); + final NamedWriteableRegistry registry = new NamedWriteableRegistry(new XPackClientPlugin(settings).getNamedWriteables()); final NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry); final RoleMapperExpression exprResult = ExpressionParser.readExpression(input); assertThat(json(exprResult), equalTo(json.replaceAll("\\s", ""))); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldPredicateTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldPredicateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldPredicateTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/expressiondsl/FieldPredicateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AnalyzeTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AnalyzeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/AnalyzeTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AnalyzeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 277c10c6364..76d6ba57db2 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -113,17 +113,17 @@ import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.elasticsearch.xpack.security.authc.Authentication; import org.elasticsearch.xpack.security.authc.Authentication.RealmRef; import org.elasticsearch.xpack.security.authc.DefaultAuthenticationFailureHandler; -import org.elasticsearch.xpack.security.authc.esnative.NativeRealm; +import org.elasticsearch.xpack.security.authc.esnative.NativeRealmSettings; import org.elasticsearch.xpack.security.authc.esnative.ReservedRealm; -import org.elasticsearch.xpack.security.authc.file.FileRealm; -import org.elasticsearch.xpack.security.authc.ldap.LdapRealm; -import org.elasticsearch.xpack.security.authc.pki.PkiRealm; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; +import org.elasticsearch.xpack.security.authc.ldap.LdapRealmSettings; +import org.elasticsearch.xpack.security.authc.pki.PkiRealmSettings; import org.elasticsearch.xpack.security.authz.RoleDescriptor.IndicesPrivileges; import org.elasticsearch.xpack.security.authz.accesscontrol.IndicesAccessControl; import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsCache; import org.elasticsearch.xpack.security.authz.permission.Role; -import org.elasticsearch.xpack.security.authz.store.ClientReservedRoles; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; +import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore; import org.elasticsearch.xpack.security.user.AnonymousUser; import org.elasticsearch.xpack.security.user.ElasticUser; import org.elasticsearch.xpack.security.user.SystemUser; @@ -217,7 +217,8 @@ public class AuthorizationServiceTests extends ESTestCase { // A failure would throw an exception authorize(createAuthentication(SystemUser.INSTANCE), "indices:monitor/whatever", request); - verify(auditTrail).accessGranted(SystemUser.INSTANCE, "indices:monitor/whatever", request, new String[] { SystemUser.ROLE_NAME }); + verify(auditTrail).accessGranted(SystemUser.INSTANCE, "indices:monitor/whatever", request, + new String[] { SystemUser.ROLE_NAME }); authorize(createAuthentication(SystemUser.INSTANCE), "internal:whatever", request); verify(auditTrail).accessGranted(SystemUser.INSTANCE, "internal:whatever", request, new String[] { SystemUser.ROLE_NAME }); @@ -238,7 +239,8 @@ public class AuthorizationServiceTests extends ESTestCase { assertThrowsAuthorizationException( () -> authorize(createAuthentication(SystemUser.INSTANCE), "cluster:admin/whatever", request), "cluster:admin/whatever", SystemUser.INSTANCE.principal()); - verify(auditTrail).accessDenied(SystemUser.INSTANCE, "cluster:admin/whatever", request, new String[] { SystemUser.ROLE_NAME }); + verify(auditTrail).accessDenied(SystemUser.INSTANCE, "cluster:admin/whatever", request, + new String[] { SystemUser.ROLE_NAME }); verifyNoMoreInteractions(auditTrail); } @@ -379,7 +381,8 @@ public class AuthorizationServiceTests extends ESTestCase { { //ignore_unavailable set to false, user is not authorized for this index nor does it exist SearchRequest searchRequest = new SearchRequest("does_not_exist") - .indicesOptions(IndicesOptions.fromOptions(false, true, true, false)); + .indicesOptions(IndicesOptions.fromOptions(false, true, + true, false)); assertThrowsAuthorizationException( () -> authorize(createAuthentication(user), SearchAction.NAME, searchRequest), @@ -391,12 +394,13 @@ public class AuthorizationServiceTests extends ESTestCase { { //ignore_unavailable and allow_no_indices both set to true, user is not authorized for this index nor does it exist SearchRequest searchRequest = new SearchRequest("does_not_exist") - .indicesOptions(IndicesOptions.fromOptions(true, true, true, false)); + .indicesOptions(IndicesOptions.fromOptions(true, true, + true, false)); authorize(createAuthentication(user), SearchAction.NAME, searchRequest); verify(auditTrail).accessGranted(user, SearchAction.NAME, searchRequest, new String[] { role.getName() }); - IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationService.INDICES_PERMISSIONS_KEY); + IndicesAccessControl indicesAccessControl = threadContext.getTransient(AuthorizationServiceField.INDICES_PERMISSIONS_KEY); IndicesAccessControl.IndexAccessControl indexAccessControl = - indicesAccessControl.getIndexPermissions(IndicesAndAliasesResolver.NO_INDEX_PLACEHOLDER); + indicesAccessControl.getIndexPermissions(IndicesAndAliasesResolverField.NO_INDEX_PLACEHOLDER); assertFalse(indexAccessControl.getFieldPermissions().hasFieldLevelSecurity()); assertNull(indexAccessControl.getQueries()); } @@ -570,7 +574,7 @@ public class AuthorizationServiceTests extends ESTestCase { public void testRunAsRequestWithoutLookedUpBy() { AuthenticateRequest request = new AuthenticateRequest("run as me"); - roleMap.put("can run as", ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR); + roleMap.put("can run as", ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR); User user = new User("run as me", Strings.EMPTY_ARRAY, new User("test user", new String[] { "can run as" })); Authentication authentication = new Authentication(user, new RealmRef("foo", "bar", "baz"), null); assertNotEquals(user.authenticatedUser(), user); @@ -578,7 +582,7 @@ public class AuthorizationServiceTests extends ESTestCase { () -> authorize(authentication, AuthenticateAction.NAME, request), AuthenticateAction.NAME, "test user", "run as me"); // run as [run as me] verify(auditTrail).runAsDenied(user, AuthenticateAction.NAME, request, - new String[] { ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName() }); + new String[] { ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName() }); verifyNoMoreInteractions(auditTrail); } @@ -676,9 +680,12 @@ public class AuthorizationServiceTests extends ESTestCase { .build()); List> requests = new ArrayList<>(); - requests.add(new Tuple<>(BulkAction.NAME + "[s]", new DeleteRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); - requests.add(new Tuple<>(UpdateAction.NAME, new UpdateRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); - requests.add(new Tuple<>(BulkAction.NAME + "[s]", new IndexRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(BulkAction.NAME + "[s]", + new DeleteRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(UpdateAction.NAME, + new UpdateRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(BulkAction.NAME + "[s]", + new IndexRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); requests.add(new Tuple<>(SearchAction.NAME, new SearchRequest(SecurityLifecycleService.SECURITY_INDEX_NAME))); requests.add(new Tuple<>(TermVectorsAction.NAME, new TermVectorsRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); @@ -749,8 +756,8 @@ public class AuthorizationServiceTests extends ESTestCase { } public void testSuperusersCanExecuteOperationAgainstSecurityIndex() { - final User superuser = new User("custom_admin", ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName()); - roleMap.put(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName(), ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR); + final User superuser = new User("custom_admin", ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName()); + roleMap.put(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName(), ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR); ClusterState state = mock(ClusterState.class); when(clusterService.state()).thenReturn(state); when(state.metaData()).thenReturn(MetaData.builder() @@ -760,11 +767,14 @@ public class AuthorizationServiceTests extends ESTestCase { .build()); List> requests = new ArrayList<>(); - requests.add(new Tuple<>(DeleteAction.NAME, new DeleteRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(DeleteAction.NAME, + new DeleteRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); requests.add(new Tuple<>(BulkAction.NAME + "[s]", createBulkShardRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, DeleteRequest::new))); - requests.add(new Tuple<>(UpdateAction.NAME, new UpdateRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); - requests.add(new Tuple<>(IndexAction.NAME, new IndexRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(UpdateAction.NAME, + new UpdateRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); + requests.add(new Tuple<>(IndexAction.NAME, + new IndexRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, "type", "id"))); requests.add(new Tuple<>(BulkAction.NAME + "[s]", createBulkShardRequest(SecurityLifecycleService.SECURITY_INDEX_NAME, IndexRequest::new))); requests.add(new Tuple<>(SearchAction.NAME, new SearchRequest(SecurityLifecycleService.SECURITY_INDEX_NAME))); @@ -788,8 +798,8 @@ public class AuthorizationServiceTests extends ESTestCase { } public void testSuperusersCanExecuteOperationAgainstSecurityIndexWithWildcard() { - final User superuser = new User("custom_admin", ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName()); - roleMap.put(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName(), ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR); + final User superuser = new User("custom_admin", ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName()); + roleMap.put(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName(), ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR); ClusterState state = mock(ClusterState.class); when(clusterService.state()).thenReturn(state); when(state.metaData()).thenReturn(MetaData.builder() @@ -964,9 +974,11 @@ public class AuthorizationServiceTests extends ESTestCase { final String action = BulkAction.NAME + "[s]"; final BulkItemRequest[] items = { new BulkItemRequest(1, new IndexRequest("", "doc", "dy1")), - new BulkItemRequest(2, new DeleteRequest("", "doc", "dy2")), // resolves to same as above + new BulkItemRequest(2, + new DeleteRequest("", "doc", "dy2")), // resolves to same as above new BulkItemRequest(3, new IndexRequest("", "doc", "dm1")), - new BulkItemRequest(4, new DeleteRequest("", "doc", "dm2")), // resolves to same as above + new BulkItemRequest(4, + new DeleteRequest("", "doc", "dm2")), // resolves to same as above }; final ShardId shardId = new ShardId("concrete-index", UUID.randomUUID().toString(), 1); final TransportRequest request = new BulkShardRequest(shardId, WriteRequest.RefreshPolicy.IMMEDIATE, items); @@ -979,7 +991,8 @@ public class AuthorizationServiceTests extends ESTestCase { mockEmptyMetaData(); authorize(createAuthentication(user), action, request); - verify(auditTrail, Mockito.times(2)).accessDenied(user, DeleteAction.NAME, request, new String[] { role.getName() }); // both + verify(auditTrail, Mockito.times(2)).accessDenied(user, DeleteAction.NAME, request, + new String[] { role.getName() }); // both // deletes // should fail verify(auditTrail).accessGranted(user, action, request, new String[] { role.getName() }); // bulk request is allowed @@ -988,7 +1001,8 @@ public class AuthorizationServiceTests extends ESTestCase { private BulkShardRequest createBulkShardRequest(String indexName, TriFunction> req) { final BulkItemRequest[] items = { new BulkItemRequest(1, req.apply(indexName, "type", "id")) }; - return new BulkShardRequest(new ShardId(indexName, UUID.randomUUID().toString(), 1), WriteRequest.RefreshPolicy.IMMEDIATE, items); + return new BulkShardRequest(new ShardId(indexName, UUID.randomUUID().toString(), 1), + WriteRequest.RefreshPolicy.IMMEDIATE, items); } public void testSameUserPermission() { @@ -1003,7 +1017,8 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealmSettings.TYPE) : + randomAlphaOfLengthBetween(4, 12)); assertThat(request, instanceOf(UserRequest.class)); assertTrue(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -1023,7 +1038,8 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authenticatedBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealmSettings.TYPE) : + randomAlphaOfLengthBetween(4, 12)); assertThat(request, instanceOf(UserRequest.class)); assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -1032,7 +1048,8 @@ public class AuthorizationServiceTests extends ESTestCase { final RealmRef lookedUpBy = mock(RealmRef.class); when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); when(lookedUpBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealmSettings.TYPE) : + randomAlphaOfLengthBetween(4, 12)); // this should still fail since the username is still different assertFalse(AuthorizationService.checkSameUserPermissions(action, request, authentication)); @@ -1079,7 +1096,8 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); when(lookedUpBy.getType()) - .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealm.TYPE) : randomAlphaOfLengthBetween(4, 12)); + .thenReturn(changePasswordRequest ? randomFrom(ReservedRealm.TYPE, NativeRealmSettings.TYPE) : + randomAlphaOfLengthBetween(4, 12)); assertTrue(AuthorizationService.checkSameUserPermissions(action, request, authentication)); when(authentication.getUser()).thenReturn(authUser); @@ -1094,7 +1112,8 @@ public class AuthorizationServiceTests extends ESTestCase { final RealmRef authenticatedBy = mock(RealmRef.class); when(authentication.getUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); - when(authenticatedBy.getType()).thenReturn(randomFrom(LdapRealm.LDAP_TYPE, FileRealm.TYPE, LdapRealm.AD_TYPE, PkiRealm.TYPE, + when(authenticatedBy.getType()).thenReturn(randomFrom(LdapRealmSettings.LDAP_TYPE, FileRealmSettings.TYPE, + LdapRealmSettings.AD_TYPE, PkiRealmSettings.TYPE, randomAlphaOfLengthBetween(4, 12))); assertThat(request, instanceOf(UserRequest.class)); @@ -1116,7 +1135,8 @@ public class AuthorizationServiceTests extends ESTestCase { when(authentication.getUser()).thenReturn(user); when(authentication.getAuthenticatedBy()).thenReturn(authenticatedBy); when(authentication.getLookedUpBy()).thenReturn(lookedUpBy); - when(lookedUpBy.getType()).thenReturn(randomFrom(LdapRealm.LDAP_TYPE, FileRealm.TYPE, LdapRealm.AD_TYPE, PkiRealm.TYPE, + when(lookedUpBy.getType()).thenReturn(randomFrom(LdapRealmSettings.LDAP_TYPE, FileRealmSettings.TYPE, + LdapRealmSettings.AD_TYPE, PkiRealmSettings.TYPE, randomAlphaOfLengthBetween(4, 12))); assertThat(request, instanceOf(UserRequest.class)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index 4b741ed724a..656ff870f60 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -64,8 +64,8 @@ import org.elasticsearch.xpack.security.authz.IndicesAndAliasesResolver.Resolved import org.elasticsearch.xpack.security.authz.RoleDescriptor.IndicesPrivileges; import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsCache; import org.elasticsearch.xpack.security.authz.permission.Role; -import org.elasticsearch.xpack.security.authz.store.ClientReservedRoles; import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore; +import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore; import org.elasticsearch.xpack.security.test.SecurityTestUtils; import org.elasticsearch.xpack.security.user.AnonymousUser; import org.elasticsearch.xpack.security.user.User; @@ -148,7 +148,7 @@ public class IndicesAndAliasesResolverTests extends ESTestCase { roleMap.put("dash", new RoleDescriptor("dash", null, new IndicesPrivileges[] { IndicesPrivileges.builder().indices(dashIndices).privileges("all").build() }, null)); roleMap.put("test", new RoleDescriptor("role", new String[] { "monitor" }, null, null)); - roleMap.put(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName(), ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR); + roleMap.put(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName(), ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR); final FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY); doAnswer((i) -> { ActionListener callback = @@ -1337,7 +1337,7 @@ public class IndicesAndAliasesResolverTests extends ESTestCase { private static void assertNoIndices(IndicesRequest.Replaceable request, ResolvedIndices resolvedIndices) { final List localIndices = resolvedIndices.getLocal(); assertEquals(1, localIndices.size()); - assertEquals(IndicesAndAliasesResolver.NO_INDEX_PLACEHOLDER, localIndices.iterator().next()); + assertEquals(IndicesAndAliasesResolverField.NO_INDEX_PLACEHOLDER, localIndices.iterator().next()); assertEquals(IndicesAndAliasesResolver.NO_INDICES_LIST, Arrays.asList(request.indices())); assertEquals(0, resolvedIndices.getRemote().size()); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RoleDescriptorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java index 8f875405e11..ce5ddd77da5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SecurityScrollTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.search.SearchContextMissingException; import org.elasticsearch.test.SecurityIntegTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.junit.After; @@ -32,7 +32,7 @@ public class SecurityScrollTests extends SecurityIntegTestCase { securityClient().preparePutRole("scrollable") .addIndices(new String[] { randomAlphaOfLengthBetween(4, 12) }, new String[] { "read" }, null, null, null) .get(); - securityClient().preparePutUser("other", SecuritySettingsSource.TEST_PASSWORD.toCharArray(), "scrollable").get(); + securityClient().preparePutUser("other", SecuritySettingsSourceField.TEST_PASSWORD.toCharArray(), "scrollable").get(); final int numDocs = randomIntBetween(4, 16); IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs]; @@ -59,7 +59,7 @@ public class SecurityScrollTests extends SecurityIntegTestCase { SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client() .filterWithHeader(Collections.singletonMap("Authorization", - UsernamePasswordToken.basicAuthHeaderValue("other", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))) + UsernamePasswordToken.basicAuthHeaderValue("other", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))) .prepareSearchScroll(scrollId) .get()); for (ShardSearchFailure failure : e.shardFailures()) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListenerTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListenerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListenerTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SecuritySearchOperationListenerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReaderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReaderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReaderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/DocumentSubsetReaderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldExtractorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReaderTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReaderTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReaderTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldSubsetReaderTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesAccessControlTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCacheTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCacheTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCacheTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/OptOutQueryCacheTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SecurityIndexSearcherWrapperUnitTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorFactoryTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorFactoryTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/SetSecurityUserProcessorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsCacheTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/FieldPermissionsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/privilege/PrivilegeTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/privilege/PrivilegeTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/privilege/PrivilegeTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/privilege/PrivilegeTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java index be967c75477..e9136bfaaad 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java @@ -206,8 +206,8 @@ public class CompositeRolesStoreTests extends ESTestCase { final int numberOfTimesToCall = scaledRandomIntBetween(0, 32); final boolean getSuperuserRole = randomBoolean() - && roleName.equals(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName()) == false; - final Set names = getSuperuserRole ? Sets.newHashSet(roleName, ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR.getName()) + && roleName.equals(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName()) == false; + final Set names = getSuperuserRole ? Sets.newHashSet(roleName, ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR.getName()) : Collections.singleton(roleName); for (int i = 0; i < numberOfTimesToCall; i++) { future = new PlainActionFuture<>(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java index 3102852fee2..1d15c1f9afa 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java @@ -18,7 +18,7 @@ import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.audit.logfile.CapturingLogger; import org.elasticsearch.xpack.security.authz.RoleDescriptor; import org.elasticsearch.xpack.security.authz.permission.ClusterPermission; @@ -302,7 +302,7 @@ public class FileRolesStoreTests extends ESTestCase { try { Path roles = getDataPath("roles.yml"); Path home = createTempDir(); - Path xpackConf = home.resolve("config").resolve(XpackField.NAME); + Path xpackConf = home.resolve("config").resolve(XPackField.NAME); Files.createDirectories(xpackConf); Path tmp = xpackConf.resolve("roles.yml"); try (OutputStream stream = Files.newOutputStream(tmp)) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java index 9856c74b5d6..1d44e5f4098 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java @@ -39,6 +39,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.elasticsearch.xpack.security.action.role.PutRoleRequest; import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; import org.elasticsearch.xpack.security.authz.RoleDescriptor; @@ -259,7 +260,7 @@ public class NativeRolesStoreTests extends ESTestCase { .build(); MetaData metaData = MetaData.builder() .put(IndexMetaData.builder(securityIndexName).settings(settings)) - .put(new IndexTemplateMetaData(SecurityLifecycleService.SECURITY_TEMPLATE_NAME, 0, 0, + .put(new IndexTemplateMetaData(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME, 0, 0, Collections.singletonList(securityIndexName), Settings.EMPTY, ImmutableOpenMap.of(), ImmutableOpenMap.of(), ImmutableOpenMap.of())) .build(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/RestRequestFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java index 6764dbf3125..387147a9b20 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/SecurityRestFilterTests.java @@ -21,7 +21,7 @@ import org.elasticsearch.rest.RestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.xpack.security.authc.Authentication; import org.elasticsearch.xpack.security.authc.Authentication.RealmRef; @@ -113,7 +113,7 @@ public class SecurityRestFilterTests extends ESTestCase { public void testProcessFiltersBodyCorrectly() throws Exception { FakeRestRequest restRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) - .withContent(new BytesArray("{\"password\": \"" + SecuritySettingsSource.TEST_PASSWORD + "\", \"foo\": \"bar\"}"), + .withContent(new BytesArray("{\"password\": \"" + SecuritySettingsSourceField.TEST_PASSWORD + "\", \"foo\": \"bar\"}"), XContentType.JSON).build(); when(channel.request()).thenReturn(restRequest); SetOnce handlerRequest = new SetOnce<>(); @@ -145,7 +145,7 @@ public class SecurityRestFilterTests extends ESTestCase { Map original = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, handlerRequest.get() .content()).map(); assertEquals(2, original.size()); - assertEquals(SecuritySettingsSource.TEST_PASSWORD, original.get("password")); + assertEquals(SecuritySettingsSourceField.TEST_PASSWORD, original.get("password")); assertEquals("bar", original.get("foo")); assertNotEquals(restRequest, authcServiceRequest.get()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java index b71c76c9a86..900b0ab903e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.yaml.ObjectPath; import org.elasticsearch.xpack.security.authz.AuthorizationService; import org.elasticsearch.xpack.security.user.AnonymousUser; @@ -51,7 +52,7 @@ public class RestAuthenticateActionTests extends SecurityIntegTestCase { public void testAuthenticateApi() throws Exception { Response response = getRestClient().performRequest("GET", "/_xpack/security/_authenticate", new BasicHeader("Authorization", basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, - new SecureString(SecuritySettingsSource.TEST_PASSWORD.toCharArray())))); + new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray())))); assertThat(response.getStatusLine().getStatusCode(), is(200)); ObjectPath objectPath = ObjectPath.createFromResponse(response); assertThat(objectPath.evaluate("username").toString(), equalTo(SecuritySettingsSource.TEST_USER_NAME)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandlerTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandlerTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/SecurityBaseRestHandlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java index 4c181862a47..582deffc5c5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/oauth2/RestGetTokenActionTests.java @@ -17,7 +17,7 @@ import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.xpack.security.action.token.CreateTokenRequest; import org.elasticsearch.xpack.security.action.token.CreateTokenResponse; @@ -86,7 +86,7 @@ public class RestGetTokenActionTests extends ESTestCase { final String request = "{" + "\"grant_type\": \"password\"," + "\"username\": \"user1\"," + - "\"password\": \"" + SecuritySettingsSource.TEST_PASSWORD + "\"," + + "\"password\": \"" + SecuritySettingsSourceField.TEST_PASSWORD + "\"," + "\"scope\": \"FULL\"" + "}"; try (XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, request)) { @@ -94,7 +94,7 @@ public class RestGetTokenActionTests extends ESTestCase { assertEquals("password", createTokenRequest.getGrantType()); assertEquals("user1", createTokenRequest.getUsername()); assertEquals("FULL", createTokenRequest.getScope()); - assertTrue(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING.equals(createTokenRequest.getPassword())); + assertTrue(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING.equals(createTokenRequest.getPassword())); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/user/HasPrivilegesRestResponseTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/user/HasPrivilegesRestResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/rest/action/user/HasPrivilegesRestResponseTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/rest/action/user/HasPrivilegesRestResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/AutomatonsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/AutomatonsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/AutomatonsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/support/AutomatonsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/support/IndexLifecycleManagerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/support/ValidationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityTestUtils.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java index 5c0490a01fb..5ad8f00c659 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeValidationException; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectionProfile; @@ -27,11 +28,11 @@ import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportResponse; import org.elasticsearch.transport.TransportResponseHandler; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.security.Security; -import org.elasticsearch.xpack.security.authc.file.FileRealm; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.SecurityField; +import org.elasticsearch.xpack.security.authc.file.FileRealmSettings; import org.elasticsearch.xpack.ssl.SSLClientAuth; import org.junit.BeforeClass; @@ -94,7 +95,7 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase public void testThatConnectionToServerTypeConnectionWorks() throws IOException, NodeValidationException { Path home = createTempDir(); - Path xpackConf = home.resolve("config").resolve(XpackField.NAME); + Path xpackConf = home.resolve("config").resolve(XPackField.NAME); Files.createDirectories(xpackConf); Transport transport = internalCluster().getDataNodeInstance(Transport.class); @@ -114,10 +115,10 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase .put("path.home", home) .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) - .put("xpack.ml.autodetect_process", false); + .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false); + //.put("xpack.ml.autodetect_process", false); addSSLSettingsForStore(nodeSettings, "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks", "testnode"); - try (Node node = new MockNode(nodeSettings.build(), Arrays.asList(XPackPlugin.class, TestZenDiscovery.TestPlugin.class))) { + try (Node node = new MockNode(nodeSettings.build(), Arrays.asList(LocalStateSecurity.class, TestZenDiscovery.TestPlugin.class))) { node.start(); ensureStableCluster(cluster().size() + 1); } @@ -125,7 +126,7 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase public void testThatConnectionToClientTypeConnectionIsRejected() throws IOException, NodeValidationException, InterruptedException { Path home = createTempDir(); - Path xpackConf = home.resolve("config").resolve(XpackField.NAME); + Path xpackConf = home.resolve("config").resolve(XPackField.NAME); Files.createDirectories(xpackConf); writeFile(xpackConf, "users", configUsers()); writeFile(xpackConf, "users_roles", configUsersRoles()); @@ -137,10 +138,10 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase // test that starting up a node works Settings.Builder nodeSettings = Settings.builder() - .put("xpack.security.authc.realms.file.type", FileRealm.TYPE) + .put("xpack.security.authc.realms.file.type", FileRealmSettings.TYPE) .put("xpack.security.authc.realms.file.order", 0) .put("node.name", "my-test-node") - .put(Security.USER_SETTING.getKey(), "test_user:" + SecuritySettingsSource.TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), "test_user:" + SecuritySettingsSourceField.TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("discovery.zen.ping.unicast.hosts", unicastHost) .put("discovery.zen.minimum_master_nodes", @@ -151,10 +152,10 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase .put("discovery.initial_state_timeout", "0s") .put("path.home", home) .put(Node.NODE_MASTER_SETTING.getKey(), false) - .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) - .put("xpack.ml.autodetect_process", false); + .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false); + //.put("xpack.ml.autodetect_process", false); addSSLSettingsForStore(nodeSettings, "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks", "testnode"); - try (Node node = new MockNode(nodeSettings.build(), Arrays.asList(XPackPlugin.class, TestZenDiscovery.TestPlugin.class))) { + try (Node node = new MockNode(nodeSettings.build(), Arrays.asList(LocalStateSecurity.class, TestZenDiscovery.TestPlugin.class))) { node.start(); TransportService instance = node.injector().getInstance(TransportService.class); try (Transport.Connection connection = instance.openConnection(new DiscoveryNode("theNode", transportAddress, Version.CURRENT), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java index 4965075b44a..2f9070bfed4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IPFilterTests.java @@ -20,6 +20,8 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.junit.annotations.Network; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.audit.AuditTrailService; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -262,9 +264,8 @@ public class IPFilterTests extends ESTestCase { .put("path.home", createTempDir()) .put("xpack.security.transport.filter.enabled", randomBoolean()) .put("xpack.security.http.filter.enabled", randomBoolean()) - .put("xpack.ml.autodetect_process", false) .build(); - try (Node node = new MockNode(settings, Collections.singletonList(XPackPlugin.class))) { + try (Node node = new MockNode(settings, Arrays.asList(LocalStateSecurity.class))) { assertNotNull(node); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/PatternRuleTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/PatternRuleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/PatternRuleTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/PatternRuleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRuleTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRuleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRuleTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/filter/SecurityIpFilterRuleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java similarity index 93% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java index 332c51f4424..2539e4a2f9e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/DNSOnlyHostnameVerificationTests.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.ssl.CertUtils; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -76,7 +77,7 @@ public class DNSOnlyHostnameVerificationTests extends SecurityIntegTestCase { keystore = KeyStore.getInstance("JKS"); keystore.load(null, null); - keystore.setKeyEntry("private key", keyPair.getPrivate(), SecuritySettingsSource.TEST_PASSWORD.toCharArray(), + keystore.setKeyEntry("private key", keyPair.getPrivate(), SecuritySettingsSourceField.TEST_PASSWORD.toCharArray(), new Certificate[]{cert}); } @@ -99,15 +100,15 @@ public class DNSOnlyHostnameVerificationTests extends SecurityIntegTestCase { .put("transport.host", hostName); Path keystorePath = nodeConfigPath(nodeOrdinal).resolve("keystore.jks"); try (OutputStream os = Files.newOutputStream(keystorePath)) { - keystore.store(os, SecuritySettingsSource.TEST_PASSWORD.toCharArray()); + keystore.store(os, SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()); } catch (IOException e) { throw new UncheckedIOException(e); } catch (CertificateException | NoSuchAlgorithmException | KeyStoreException e) { throw new ElasticsearchException("unable to write keystore for node", e); } SecuritySettingsSource.addSecureSettings(builder, secureSettings -> { - secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSource.TEST_PASSWORD); - secureSettings.setString("xpack.ssl.truststore.secure_password", SecuritySettingsSource.TEST_PASSWORD); + secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSourceField.TEST_PASSWORD); + secureSettings.setString("xpack.ssl.truststore.secure_password", SecuritySettingsSourceField.TEST_PASSWORD); }); builder.put("xpack.ssl.keystore.path", keystorePath.toAbsolutePath()) .put("xpack.ssl.truststore.path", keystorePath.toAbsolutePath()); @@ -128,15 +129,15 @@ public class DNSOnlyHostnameVerificationTests extends SecurityIntegTestCase { .put(defaultSettings.filter((s) -> s.startsWith("xpack.ssl.") == false)); Path path = createTempDir().resolve("keystore.jks"); try (OutputStream os = Files.newOutputStream(path)) { - keystore.store(os, SecuritySettingsSource.TEST_PASSWORD.toCharArray()); + keystore.store(os, SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()); } catch (IOException e) { throw new UncheckedIOException(e); } catch (CertificateException | NoSuchAlgorithmException | KeyStoreException e) { throw new ElasticsearchException("unable to write keystore for node", e); } SecuritySettingsSource.addSecureSettings(builder, secureSettings -> { - secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSource.TEST_PASSWORD); - secureSettings.setString("xpack.ssl.truststore.secure_password", SecuritySettingsSource.TEST_PASSWORD); + secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSourceField.TEST_PASSWORD); + secureSettings.setString("xpack.ssl.truststore.secure_password", SecuritySettingsSourceField.TEST_PASSWORD); }); builder.put("xpack.ssl.keystore.path", path.toAbsolutePath()) .put("xpack.ssl.truststore.path", path.toAbsolutePath()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilterTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilterTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilterTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IpFilterRemoteAddressFilterTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransportTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransportTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransportTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4ServerTransportTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java index 8ad668cd60d..67f7fd5f1e7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SslHostnameVerificationTests.java @@ -15,6 +15,8 @@ import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import java.net.InetSocketAddress; import java.nio.file.Files; @@ -90,7 +92,7 @@ public class SslHostnameVerificationTests extends SecurityIntegTestCase { .put("xpack.ssl.verification_mode", "full") .build(); - try (TransportClient client = new TestXPackTransportClient(settings)) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateSecurity.class)) { client.addTransportAddress(new TransportAddress(inetSocketAddress.getAddress(), inetSocketAddress.getPort())); client.admin().cluster().prepareHealth().get(); fail("Expected a NoNodeAvailableException due to hostname verification failures"); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java index e16fedc24e8..8cc3f645ac0 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java @@ -27,6 +27,8 @@ import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; import org.elasticsearch.xpack.common.socket.SocketAccess; +import org.elasticsearch.xpack.security.LocalStateSecurity; +import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.ssl.SSLService; import javax.net.ssl.SSLContext; @@ -64,7 +66,7 @@ public class SslIntegrationTests extends SecurityIntegTestCase { .put("node.name", "programmatic_transport_client") .put("cluster.name", internalCluster().getClusterName()) .putList("xpack.ssl.cipher_suites", "TLS_ECDH_anon_WITH_RC4_128_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA") - .build())) { + .build(), LocalStateSecurity.class)) { TransportAddress transportAddress = randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses()); transportClient.addTransportAddress(transportAddress); @@ -83,7 +85,7 @@ public class SslIntegrationTests extends SecurityIntegTestCase { .put("node.name", "programmatic_transport_client") .put("cluster.name", internalCluster().getClusterName()) .putList("xpack.ssl.supported_protocols", new String[]{"SSLv3"}) - .build())) { + .build(), LocalStateSecurity.class)) { TransportAddress transportAddress = randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses()); transportClient.addTransportAddress(transportAddress); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java similarity index 87% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java index bcb4773310e..8d752bf45a7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java @@ -12,15 +12,18 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; +import org.elasticsearch.xpack.security.LocalStateSecurity; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.ssl.SSLClientAuth; import org.junit.BeforeClass; import java.net.InetAddress; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; -import static org.elasticsearch.test.SecuritySettingsSource.TEST_PASSWORD; +import static org.elasticsearch.test.SecuritySettingsSourceField.TEST_PASSWORD; import static org.elasticsearch.test.SecuritySettingsSource.TEST_USER_NAME; import static org.elasticsearch.test.SecuritySettingsSource.addSSLSettingsForStore; import static org.hamcrest.CoreMatchers.is; @@ -87,8 +90,9 @@ public class SslMultiPortTests extends SecurityIntegTestCase { .put("xpack.security.transport.ssl.enabled", true) .put(additionalSettings) .build(); + //return new TestXPackTransportClient(settings, LocalStateSecurity.class); logger.info("transport client settings:\n{}", settings); - return new TestXPackTransportClient(settings); + return new TestXPackTransportClient(settings, LocalStateSecurity.class); } /** @@ -112,7 +116,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase { .put("xpack.security.transport.ssl.enabled", true) .put("node.name", "programmatic_transport_client") .put("cluster.name", internalCluster().getClusterName()) - .build())) { + .build(), LocalStateSecurity.class)) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_client_auth"))); assertGreenClusterState(transportClient); @@ -144,7 +148,8 @@ public class SslMultiPortTests extends SecurityIntegTestCase { public void testThatProfileTransportClientCanConnectToClientProfile() throws Exception { Settings.Builder builder = Settings.builder(); addSSLSettingsForStore(builder, - "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile"); + "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", + "testclient-client-profile"); try (TransportClient transportClient = createTransportClient(builder.build())) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client"))); assertGreenClusterState(transportClient); @@ -160,7 +165,8 @@ public class SslMultiPortTests extends SecurityIntegTestCase { public void testThatProfileTransportClientCanConnectToNoClientAuthProfile() throws Exception { Settings.Builder builder = Settings.builder(); addSSLSettingsForStore(builder, - "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile"); + "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", + "testclient-client-profile"); try (TransportClient transportClient = createTransportClient(builder.build())) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_client_auth"))); @@ -177,7 +183,8 @@ public class SslMultiPortTests extends SecurityIntegTestCase { public void testThatProfileTransportClientCannotConnectToDefaultProfile() throws Exception { Settings.Builder builder = Settings.builder(); addSSLSettingsForStore(builder, - "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile"); + "/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", + "testclient-client-profile"); try (TransportClient transportClient = createTransportClient(builder.build())) { TransportAddress transportAddress = randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses()); transportClient.addTransportAddress(transportAddress); @@ -194,10 +201,11 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientCannotConnectToDefaultProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses())); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -212,10 +220,11 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientCannotConnectToClientProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client"))); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -230,10 +239,11 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientCannotConnectToNoClientAuthProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_client_auth"))); assertGreenClusterState(transportClient); @@ -250,14 +260,15 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientWithOnlyTruststoreCanConnectToNoClientAuthProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.security.transport.ssl.enabled", true) .put("xpack.ssl.truststore.path", getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks")) .put("xpack.ssl.truststore.password", "truststore-testnode-only") .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_client_auth"))); } @@ -271,7 +282,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientWithOnlyTruststoreCannotConnectToClientProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.security.transport.ssl.enabled", true) .put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED) @@ -279,7 +290,8 @@ public class SslMultiPortTests extends SecurityIntegTestCase { getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks")) .put("xpack.ssl.truststore.password", "truststore-testnode-only") .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client"))); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -296,7 +308,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatTransportClientWithOnlyTruststoreCannotConnectToDefaultProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.security.transport.ssl.enabled", true) .put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED) @@ -304,7 +316,8 @@ public class SslMultiPortTests extends SecurityIntegTestCase { getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks")) .put("xpack.ssl.truststore.password", "truststore-testnode-only") .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses())); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -320,12 +333,13 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatSSLTransportClientWithNoTruststoreCannotConnectToDefaultProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED) .put("xpack.security.transport.ssl.enabled", true) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses())); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -341,12 +355,13 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatSSLTransportClientWithNoTruststoreCannotConnectToClientProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED) .put("xpack.security.transport.ssl.enabled", true) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client"))); assertGreenClusterState(transportClient); fail("Expected NoNodeAvailableException"); @@ -362,12 +377,13 @@ public class SslMultiPortTests extends SecurityIntegTestCase { */ public void testThatSSLTransportClientWithNoTruststoreCannotConnectToNoClientAuthProfile() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) + .put(SecurityField.USER_SETTING.getKey(), TEST_USER_NAME + ":" + TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) .put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED) .put("xpack.security.transport.ssl.enabled", true) .build(); - try (TransportClient transportClient = new TestXPackTransportClient(settings)) { + try (TransportClient transportClient = new TestXPackTransportClient(settings, + Collections.singletonList(LocalStateSecurity.class))) { transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_client_auth"))); assertGreenClusterState(transportClient); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslNullCipherTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslNullCipherTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslNullCipherTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslNullCipherTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/user/AnonymousUserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/SystemUserTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/SystemUserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/user/SystemUserTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/user/SystemUserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/user/UserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java index 912d7e8e962..2618abc9248 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/security/user/XPackUserTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.search.SearchAction; import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.security.SecurityLifecycleService; -import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail; +import org.elasticsearch.xpack.security.audit.index.IndexAuditTrailField; import org.elasticsearch.xpack.security.audit.index.IndexNameResolver; import org.hamcrest.Matchers; import org.joda.time.DateTime; @@ -49,6 +49,6 @@ public class XPackUserTests extends ESTestCase { private String getAuditLogName() { final DateTime date = new DateTime().plusDays(randomIntBetween(1, 360)); final IndexNameResolver.Rollover rollover = randomFrom(IndexNameResolver.Rollover.values()); - return IndexNameResolver.resolve(IndexAuditTrail.INDEX_NAME_PREFIX, date, rollover); + return IndexNameResolver.resolve(IndexAuditTrailField.INDEX_NAME_PREFIX, date, rollover); } } \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java index f6e7e74115d..383177ee2df 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLClientAuthTests.java @@ -22,7 +22,9 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.transport.Transport; import org.elasticsearch.xpack.TestXPackTransportClient; +import org.elasticsearch.xpack.security.LocalStateSecurity; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; @@ -98,10 +100,10 @@ public class SSLClientAuthTests extends SecurityIntegTestCase { .put("xpack.ssl.keystore.path", store) .setSecureSettings(secureSettings) .put("cluster.name", internalCluster().getClusterName()) - .put(Security.USER_SETTING.getKey(), + .put(SecurityField.USER_SETTING.getKey(), transportClientUsername() + ":" + new String(transportClientPassword().getChars())) .build(); - try (TransportClient client = new TestXPackTransportClient(settings)) { + try (TransportClient client = new TestXPackTransportClient(settings, LocalStateSecurity.class)) { Transport transport = internalCluster().getDataNodeInstance(Transport.class); TransportAddress transportAddress = transport.boundAddress().publishAddress(); client.addTransportAddress(transportAddress); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java index 294c157ebe9..1615fba197c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java +++ b/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLReloadIntegTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.transport.Transport; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -94,14 +95,14 @@ public class SSLReloadIntegTests extends SecurityIntegTestCase { X509Certificate certificate = getCertificate(keyPair); KeyStore keyStore = KeyStore.getInstance("jks"); keyStore.load(null, null); - keyStore.setKeyEntry("key", keyPair.getPrivate(), SecuritySettingsSource.TEST_PASSWORD.toCharArray(), + keyStore.setKeyEntry("key", keyPair.getPrivate(), SecuritySettingsSourceField.TEST_PASSWORD.toCharArray(), new Certificate[] { certificate }); Path keystorePath = createTempDir().resolve("newcert.jks"); try (OutputStream out = Files.newOutputStream(keystorePath)) { - keyStore.store(out, SecuritySettingsSource.TEST_PASSWORD.toCharArray()); + keyStore.store(out, SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()); } MockSecureSettings secureSettings = new MockSecureSettings(); - secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSource.TEST_PASSWORD); + secureSettings.setString("xpack.ssl.keystore.secure_password", SecuritySettingsSourceField.TEST_PASSWORD); secureSettings.setString("xpack.ssl.truststore.secure_password", "testnode"); Settings settings = Settings.builder() .put("path.home", createTempDir()) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLTrustRestrictionsTests.java b/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLTrustRestrictionsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/SSLTrustRestrictionsTests.java rename to plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLTrustRestrictionsTests.java diff --git a/plugin/src/test/resources/IndexLifecycleManagerTests-template.json b/plugin/security/src/test/resources/IndexLifecycleManagerTests-template.json similarity index 100% rename from plugin/src/test/resources/IndexLifecycleManagerTests-template.json rename to plugin/security/src/test/resources/IndexLifecycleManagerTests-template.json diff --git a/plugin/src/test/resources/missing-version-security-index-template.json b/plugin/security/src/test/resources/missing-version-security-index-template.json similarity index 100% rename from plugin/src/test/resources/missing-version-security-index-template.json rename to plugin/security/src/test/resources/missing-version-security-index-template.json diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/action/role/roles2xformat.json b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/action/role/roles2xformat.json similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/action/role/roles2xformat.json rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/action/role/roles2xformat.json diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/file/users b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/file/users similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/file/users rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/file/users diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/file/users_roles b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/file/users_roles similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/file/users_roles rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/file/users_roles diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad-schema.ldif b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad-schema.ldif similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad-schema.ldif rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad-schema.ldif diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad.ldif b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad.ldif similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad.ldif rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/ad.ldif diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/role_mapping.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/role_mapping.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/role_mapping.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/role_mapping.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithGroupSearch.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithGroupSearch.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithGroupSearch.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithGroupSearch.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithRoleMapping.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithRoleMapping.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithRoleMapping.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldapWithRoleMapping.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldaptrust.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldaptrust.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldaptrust.jks rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/ldaptrust.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/seven-seas.ldif b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/seven-seas.ldif similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/seven-seas.ldif rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/ldap/support/seven-seas.ldif diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/pki/role_mapping.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/pki/role_mapping.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/pki/role_mapping.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/pki/role_mapping.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authc/support/role_mapping.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/support/role_mapping.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authc/support/role_mapping.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authc/support/role_mapping.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/default_roles.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/default_roles.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/default_roles.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/default_roles.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/invalid_roles.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/invalid_roles.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/invalid_roles.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/invalid_roles.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/reserved_roles.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/reserved_roles.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/reserved_roles.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/reserved_roles.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.json b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.json similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.json rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.json diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/authz/store/roles2xformat.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode-different-passwords.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode-different-passwords.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode-different-passwords.jks rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode-different-passwords.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.cert b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.cert similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.cert rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.cert diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/roles.yml b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/roles.yml similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/roles.yml rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/roles.yml diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/users b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/users similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/users rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/users diff --git a/plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/users_roles b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/users_roles similarity index 100% rename from plugin/src/test/resources/org/elasticsearch/xpack/security/plugin/users_roles rename to plugin/security/src/test/resources/org/elasticsearch/xpack/security/plugin/users_roles diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc new file mode 100644 index 00000000000..5b2a6b737d7 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/README.asciidoc @@ -0,0 +1,36 @@ += Keystore Details +This document details the steps used to create the certificate and keystore files in this directory. + +== Instructions on generating self-signed certificates +The certificates in this directory have been generated using the following openssl configuration and commands. + +OpenSSL Configuration File is located in this directory as `openssl_config.cnf`. + +NOTE: The `alt_names` section provides the Subject Alternative Names for each certificate. This is necessary for testing +with hostname verification enabled. + +[source,shell] +----------------------------------------------------------------------------------------------------------- +openssl req -new -x509 -extensions v3_req -out .cert -keyout .pem -days 1460 -config config.cnf +----------------------------------------------------------------------------------------------------------- + +When prompted the password is always set to the value of . + +Because we intend to import these certificates into a Java Keystore file, they certificate and private key must be combined +in a PKCS12 certificate. + +[source,shell] +----------------------------------------------------------------------------------------------------------- +openssl pkcs12 -export -name -in .cert -inkey .pem -out .p12 +----------------------------------------------------------------------------------------------------------- + +== Creating the Keystore +We need to create a keystore from the created PKCS12 certificate. + +[source,shell] +----------------------------------------------------------------------------------------------------------- +keytool -importkeystore -destkeystore .jks -srckeystore .p12 -srcstoretype pkcs12 -alias +----------------------------------------------------------------------------------------------------------- + +The keystore is now created and has the private/public key pair. You can import additional trusted certificates using +`keytool -importcert`. When doing so make sure to specify an alias so that others can recreate the keystore if necessary. diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt new file mode 100644 index 00000000000..453d1361ce4 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/active-directory-ca.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID1zCCAr+gAwIBAgIQWA24rVK7FopAgOHfEio/VjANBgkqhkiG9w0BAQsFADB+ +MRMwEQYKCZImiZPyLGQBGRYDY29tMR0wGwYKCZImiZPyLGQBGRYNZWxhc3RpY3Nl +YXJjaDEUMBIGCgmSJomT8ixkARkWBHRlc3QxEjAQBgoJkiaJk/IsZAEZFgJhZDEe +MBwGA1UEAxMVYWQtRUxBU1RJQ1NFQVJDSEFELUNBMB4XDTE0MDgyNzE2MjI0MloX +DTI5MDgyNzE2MzI0MlowfjETMBEGCgmSJomT8ixkARkWA2NvbTEdMBsGCgmSJomT +8ixkARkWDWVsYXN0aWNzZWFyY2gxFDASBgoJkiaJk/IsZAEZFgR0ZXN0MRIwEAYK +CZImiZPyLGQBGRYCYWQxHjAcBgNVBAMTFWFkLUVMQVNUSUNTRUFSQ0hBRC1DQTCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALNNZsDJ+lhsE/pCIkNlq6/F +xwv3PU2M+E1/SbWrLEtfbb1ATnn98DwxjpCj00wS0bt26/7zrhHKyX5LaxyS27ER +8bKpLSO4qcVWzDIQnVNk2XfBrYS/Og+6Pi/Lw/ylt/vE++kHWIJBc4O6i+pPByOM +oypM6bh71kTkpK8OTPqf+HiPp0qKhRah6XVtqTc+kOCOku2+wkELbCz8RNzF9ca6 +Uu3YxLi73pNdk0wDTmg6JVaUyVRpSkjJH4BAp9SVma6Rxy6tbh4e5P+8K8lY9ptM +TBzTsDS1EhNK/92xULfQbGT814Z294pF3ARMEJ89N+aegS++kz7CqjciZ1+bA6EC +AwEAAaNRME8wCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FIEKG0KdSVNknKcMZkbTlKo7N8MjMBAGCSsGAQQBgjcVAQQDAgEAMA0GCSqGSIb3 +DQEBCwUAA4IBAQBgbWBXPbEMTEsiVWzoxmTw1wJASBdPahx6CggutjGq3ASjby4p +nVCTwE4xdDEVyFGmeslSp9+23XjBuaiqVPtYw8P8hnG269J0q4cOF/VXOccRLeOw +HVDBv2a7xzgBSwc1KB50TLv07stcBmBYNu8anN6EwGksdgjb8IjRV6U3U+IvFNrI +rGifuIc/iRZD4Clhnpxw8tCsgcrcmz9CU7CN5RxKVEpZ6ou6ZjHO8l8H0t9zWrSI +PL+33iBGHNWlyU63N93XgJtxV1em1hHryLtTTtaVZJJ3R0OrLrUpG8SQ7zCUy62f +YtImFPClUMXY03yH+4DAhflueRvY/D1AKL12 +-----END CERTIFICATE----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt new file mode 100644 index 00000000000..bcabf51acb6 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.crt @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEBzCCAu+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADBGMQswCQYDVQQGEwJVUzEW +MBQGA1UEChMNZWxhc3RpY3NlYXJjaDENMAsGA1UECxMEdGVzdDEQMA4GA1UEAxMH +cm9vdC1jYTAeFw0xNDA4MjcxNTMyNTNaFw0xNTA4MjcxNTMyNTNaME4xCzAJBgNV +BAYTAlVTMRYwFAYDVQQKEw1lbGFzdGljc2VhcmNoMQ0wCwYDVQQLEwR0ZXN0MRgw +FgYDVQQDEw9pcC0xNzItMzAtMC0xNTQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQC5iQ7DiQwT1YVoLycCGsm3p4Lp8V3uo/+sV9dA4fdpJ7i84Fq0V8g6 +0VjKMIhL8mrzbjCF8hDREO6fnuAwOM8IqladwFzEqFPnvLo/Uv5J7/BgqRN2H25x +REQrOOMRsvWZWslV4aAj3ivmYu3HU6gA0I1/OsI0MCU/kotdVRkAEcu3HL16AEGK +4CkQhw3JKt7iWm2vODQ7BZadrNvjKS6C7pqV/c4+r4T1aEQNbzvM7Br70NLqA9M4 +HeOJjyqEbbr9rHtIP9Cy0M6Lp52ho7sTA2D5b/bWCSog6DvClmj2NCySR2lR1QYF +S7qrsyE6ePq8TnyoReOAxqJdjm+tFvzzAgMBAAGjgfcwgfQwCQYDVR0TBAIwADAw +BglghkgBhvhCAQ0EIxYhWWFTVCBHZW5lcmF0ZWQgU2VydmVyIENlcnRpZmljYXRl +MBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBaAwHQYDVR0OBBYEFDH+zO6n +PQHyeqiKfo5kVYUQpSJDMHYGA1UdIwRvMG2AFO/jQiwne6+hZEs7afKnyoddejH8 +oUqkSDBGMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNZWxhc3RpY3NlYXJjaDENMAsG +A1UECxMEdGVzdDEQMA4GA1UEAxMHcm9vdC1jYYIJAOwOXHgWfvKEMA0GCSqGSIb3 +DQEBBQUAA4IBAQCk6wXIRaIQrhjD1p9wkv2tjEmnktoic8I0Z3CaHe80aLLcX5n/ +7Vlo4ccp3mWAhON7dCGSj9Qc7wj28h3CkDIIntQpErhEhEpSRU70P3SD7jn3tcrF +fu+SUwtP1YLLjU9S10Jx0eImufMj0AgwIL+axjxgCfQ+nxeLWTt35zZzQqizkSSy +PVGkY/YZy1tc4JdJl9TbwGsxWgLTHs7bD1WPAYovreblRuHNEwabwwgDK+F6G7Lh +BVYCygiuyG/MehQZSgb2LmX4O1QyVe2bZJUZQNMdZLORRdGQXf6grakdolqPIASZ +SpzwTZU5InUGvQG0HuOn//+wHZ0rih/qWV+3 +-----END CERTIFICATE----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/openldap.der new file mode 100644 index 0000000000000000000000000000000000000000..8cdc214f0eb013e65004d5f4e3f44433728524c0 GIT binary patch literal 1035 zcmXqLVqrIEVtT)TnTe4JhzxkyIJMe5+P?ELGP1HV7`Pd78*s8QhqAB^sfk6&8HT(D+#qpoVV08A;u1pv13nO!S(v>jKfgpbInh8)oY&CA zz{1Gf(A3z-)Hn*rHAUhY_>pCggn<~u9{$V%T|;vtU1I}X16@N?6N4s3C1kHKvNA9? zG4eA2#krW87#SIMcJdwW;!^7{H>O1y4h}sf< z!s=qgDT5C0Pg$Sy3|c=4ToiaWf8GNFi}M_-!sZ@`IkF=7`JP?&LH|78e@IvFx306$}@8>#Yu%7^vD$>W&SSWDq>PU1o0;gJahN zO@VgalUny4MdhxyFtKKxHh0bK$C`Rg?`BQ?d(Lis%hwDS-hAsbZ=`--xb%wovW4v9 z&VH?y++BayRD0N8*mU7s_wu<57w;BkPWYMs?HZ?+!VBv|(=xu9=uC3Y47|$5>b-0A zW<{%tUwiy&R=7THIJPLZFMqArpU+Ipj0}v68^0SgegVg?tS}3c0fT`78)rhB2V>h0 zCq`ZtWiiFb#NZGG_td=9qQsKa6ouf_qO#N?1?SYFlFYQsWT2RVAVLQt3kx$7n*%s0 z$nt|YtP2cefe|Fj$0EieV)*aOyXCfwpQ=`L)%B%>whAm&ayBRfNh`DD8{{^KynpPZ zqh7s!VT!kP=BMSS+GDE>|19)c;z6xM*u=^3hA*ZadS z?d+7Pk`9+;Q#Ma@y*MHE--5L(Wfw*DE3nM;n)AVTs-;pX+g`>ka*vn)|GzC|B8Ozw0FsiX7yJ^N+sAQL|1zGZ9#-7ZZB`INsEEAb55kiE>WP9!2 zu_Pp03?fSzk?iZx!kymp-md$ebI*JKxc}VeoZorA-|zE1zvcNZzt8UC?ji^T0{$4$X01SqKYHGdJX-ZwMQJl;$ zxk#f(Iwt_IGl5V>Xbuz`GsFtY#t*^yx}ybA2YzVm{G6`d&VK%$SU*>1U#tgO3?=fz z4&fKl-)|SQWNbmqoUsR#h!7{5vAB{l`nal+s=6IRJ;6|w{#5^mD-i&R{l@^9KoA1J z4MGtBHZTDIKoeyT2bmY_En@5C`jJ>sjtgW3VO9a0KtI%{uFQ$L$tFV$P$HAjmyg8Z z`2hddpcidZD#Uw zv3LYR2n+#0KrX%!g>OK?7*Rv;L%}Ez3h_haf(k+p=yKRplJ0J6jeYxwAck4r@|~u% zqww)RzVkxyQ7C)_0p^XvI(vKI{QL<5KSkspk_+ytv!@S%?Wb9VAoMSJzmLj3C$)V} zYWtnkqM)IS1dififI8ZQ{lBS=U-fZ_OpqX_$w%@#ADPcbx`zxI zC1X7KbuE2AhW8A>nkN#y#x<9U1)m(kp+%cHPgpbcfC*{tR{=xqI+X!Eqy^>p`_Gaai=>ln=OI;6X@;nVmC8gQsXnjuH zA(?+Vg>8#?XeXx^-X&7vft&ulaKg2~B1CCOwuwG)TC`hz!IY0EWQ%Lk|6*_lI~~62 z!?vV6^u~?t@q5*mIVH+c<5XFpMyVPL_wZc&+n0S!6ahkjOPi;y%Jpf(D|^*1lw2}& zUPo(OQ|1^yMpc>!-N^yol8~t4=iKiZKL`K`|EPPcx2LO*zv7>-Uwv_Ip5A{p0x3p| zV1l3s&^;6vGn+g!00rd0ya1z4pakfAs`@6^D?S(SsBBkVt^!f>M!^Ba;H>@F0NyKpBbcnGFQFk%@j&!vML09>~{UH`5|ZWC?GZ05}AO77M49O(?9 z)l$;Zc~*K*nXq)tf|Z!Tvdh+BM#ckyzVwADI}zq?swKS4*fdzS$?EuY93>X1%%`d@ z{6VZTgQ9V8iN~$Gf@Ao#wq8e_K(pa0gYBkk2Tl&T-p4{h~ zYG!!aK;}2a#W5}Szdn45U6AU}$mW&b$~!bBBkBs?JxjOj z^9p!^wf$BpPpUYqFRCBte?vTWeZZ)5q%;K4+`4w;)RZhGM3C4#W;|o!-V*t49sTQo zv03*D`C4dQllVb@1G^m8T*fw zZ98!W)T|;emR0W5W-s)9E04id(>#O88d=s03L??;>w4pw*?wae9^A+D=3$K|jFM^| z!>vDkXz-!PcHiQ*6hKn5uRfT)U05)eEI79eqddvS%&2bCQ5##*gr}ysk&)Q!XR(L7 zH+uN6g)-T3@yA-tU$YImKP#~oe#_hN_?O|*)xllgPZ{%7)Lw^7CuIlkFcFUf&ZQ>d zyemC}=aRCfoC6wgzZ+JvD4xCq@zvC$9FEG;l5a6EwskNpB&&E7KjWXHaS^^_iZ_Rc zWU3BXSbP(er0NPV<)>K~o!hP$4vSiT#!{ct8s>gIQ|t1g2|dsYbB5b(Z@0bas^~W> z&SS~^?&;`yvP;RZx#-@}S-tCKtAdo!Q4K@%n@DYe&%Pl`Qha0YmN04>y35`93-)Z< z))O^`a{!1DlvM8%f{A%a-&<25mBF);E!` zrFg!eckp$dRfT>%^1+S~WbF}t1GR|rHzxWwJ>0cx-nH}^({9f&k?50Oz{;-YD!JGT z{lcS`uO}U1+ia z#|-h$xST{7rN#%$v@n+oxjJC4pN(>pf1H*Ht#NKXO>+#r!i#_LN4NaRMDYwJy31f9 zzkf2(+pMp9+Ce-vf4OK-l4uE(7~?Wz(9VBuwSVCqm4D|Q6}$g(mcL_}QEsfMdYDVc za3`z=)~G{*Uw}{0R}=9u=y1`qjT5r1yE!rO8+Yd5?c~crjno4V@-8xkcAp#k7#vE(j$FP2D)#7${wF`=+xIMvv6MT?1J1OKBcGgtVFMh|Z+7oxv?fNKHz& z{3nA=+(OX~U86KcJVXory^vo=caU91o=_mt;jMa`!qzno1z6B67;8!JtT1@YyAQV>+?FAbnSU2eb(dS|@ iZ15zvK6zpnb>|AGwrnM4Wwt_LK;h-_Jg1Qds{a6QQ;;G6 literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.p12 new file mode 100644 index 0000000000000000000000000000000000000000..cece3d1243208bc55450475ffaaffa564c14c059 GIT binary patch literal 2648 zcmZA1byySJ9tZHT07eX9L%JlS85`h0K=NgjAo(IGxltlRLZwDGN=Qga2@-+`37wi8Lla3J{V=!%hhmjl@PC(o;}TG`hkvu5(xuSyOk!kJv8q#0RpK3 zAw)28?1etHxtY=|A5GPZ=?bot$-}Yc$tl_%0SDaU(n^f_*xAkWI>vHE1g>{`S4&9A+P~dVad(Xl2oJL8#|c+C%8JPandx=kPsw=4 z;2(8w?ez{M(~;uO?=jP`H-5df#H)kWhpj@GhU=!>q>Zy1BAZw(6kzNmstC3?a3EYz zT}ytb!Ce#s#*R73TL71>(%v)I?LjuN&>|a+W0|_C|B#73D77(-no4xphS+5DS+}Cn!TONa0Y8sUYEX`|m|+t($o+lCN?= zS)@?TTePWCT+3JPwoW48vqt*XBckiZ1i`H>YT+Muz|jTh4L_VKI}=^I3llxZZDX#K z`pkN*XRt`iBBAruwr0cG9Eq$p+4E#A=u#HO*2{?d?6?VD<_HxY&eI>}OFG2K5eN`Cm<*BKi+%{s2xoXax5wQWV!TlyBH>guRVW|O(}Qf%n0 zCEde&3m@>;lYdx!sp41_F_A9xGL9?h%z3FZ_mf&Mt5Lg$tH&r>MSMgAC8(Ohw{{0_~d*y1gs)hK9OjdWVb`sd?t2z)p-!h zBra=kG)m3zEq0cMadZNvfQtHj|S2+=5Z} zX^fkkZU1G{*jQ~^of+D&D^@`9^bhX-bpA(0eV*3O&q+ukB>caC$tObYgNcxP7qQ31 z!c)@zn;RMm;Dt+@7a*JYcWoZvVfNIm4LlPZ5yFtZ zho|LYaoI~N>dDZQH{yJ?R(mDiHTCL};EvSrDT{uTs>tQ?K>Co(mhoY-17S1%S-$^G zl#}ps-Yv@HPw^zjYy`xQJUU9W9Ue3KZOY8^R_}yu# znxb`Y46tmirIAv}uKP7erercAbzJyN^Kh`1`{4VRcAziur!Ax)Z>Z!If9Wr^5RBeT z)xt!Kv9`(YdB}@Uv9^li`}gD4xvWFVbU`y=-A4ikm|OFifp;+DRVyVt?V{uxvj|z; zbB!*BS`#s<#nj3EAOY&2rNK2(oO#rlFki%Jqx3gnw!Gm>Q^oj}ID6IyW&&tsK8OM5 zp~0Bto*?6OT|)kQu}1&Ilfnl%25JLcp83M8St!>~!0Si$op-O|X{S)~vv2jtGUpwn z{v1rn?W~Bvuty#ZAIgOf^ke`56|EBDDpwL7tS(J2!9L@8Cx)Mg10CvYlF-K)Q<{3) zPp_Rq{b6Y^zpR7(keMJdPx-a7cvu^`!lw*IYO1TZtI(|9HB;8uOm_L+;B|RLEpPe! zuFOKMMYEEhOZ=9xL)iU%p+KQ05-Kmumb7WD%6=!fb|?L^ur+TQeJMc*v1*MZ@`_EWV} z!>IPptVm8$5IEvaD#{vPNCahEm(P{6W!f^U^|@@nw-;+sp4s!26i(ul;5eYC*Li`= ze$y$t5+Te*#Vh);Mr4D>H-Uzhyj2pcM&8i^9n^`rNxR6WwBep5Yim>~93*Q_eQAeJ z=)w5AfqhQ&(WyZyeWMa^(c<(g{<2mUlYCs%dlFMs#VMWA!sw&aQBl(Evl^8>h44O--rp`S1y=^tnFYmUnI|HKW~oa?8%A z5%gM$hqZn-f*gpL;I$4@UDNAj=G<&AvgeF@*7jv9BJ{ne&+u{!ZHmK8d)#7o%5 z0l9bgv4k1spIz&h$DP;%?7<(B(X%5BNtzI(2-AqH}aYgAfj7qsDNKgjKgz-z6hkTD!ueP4q zUL<{p)6Hl|t4yG?rh`gqOXuA_@iyukJMIAWgN$rnyuLr{__WF@ zQ(r#Zhvs*-n~s&nA^HEKBa~VCG8p0fW=DY5Z6~y?f@sGG?EVqrG$vVKtOf~0F211jP9Ym gu5$MKOoO;uy-GpJ`56SJrt>y6mdfoH`5W550Fh?ShX4Qo literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem new file mode 100644 index 00000000000..f5ea25da696 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,02BA9C3E433F0711 + +M3Ds1K8/cp5v9BKj9SstoXWlyj+CmasLfvPlz6O5Ootdai/wTirhxyAcYcsgjuQA +FIMuQiAaKC+W/DOP52+ilY3FZKw09DptdkaU7IFvSQvJ5SeiJIGLZ9REUWIPwRKV +qCHpKFCS4//mitnykjSu2HhTM+BjbXuytLJtxFJuodr8YhJGgtwfETAmbVlwWG3M +mhEsfdr0kOJGwT/z3dZbCxnGkjOY1FZCdMU/ggeYx93NP0c4yzNU6/A0idZRMlHE +BuSIkDhn3BXxgxYxTOgHzCkxaZ0T7kNv0MvTXrrcQf2WrMaG1FfTzCzF78YDBn7+ +kg5HI8wfxjGjDTnHH9KSuN5gi14DiEEUN45Ba3ChH75SjGwBbUjnHsGIp6Ch8mh8 +5ZgldgUOff0atEBaMpvoZAzxGbY5PhC5/Pfiq+enzvmICxszFNIRMhhLxWWBWuH9 +v04OOKZJ4v+ygZHvPJEFNc/XznGb39ELn4Y6P26fqNfPmv5/yHcenQPNZgGkKQEJ +SYTPxct+yDi3lul1WBPrvZwCOAjUtcCf4tBC6uOqlRjd7VREk5hKUlXTtxJLbaoB +FH1VKn9xZITBqk3g292KGbpZsGP5HtYAbB/gJUcOXZZbr8blMmpeIXXFWfPbvUcv +d1fokqHSrlclNt+h2pENqjJTc2iKKKlkNY0ol+cDej7fOgNH0sNOjuESrofdaXfa +4CPuvMxeQFKnjQFBLM14CFUyseZsAqnLjneUnk5qTPE5twCN0pkJx0y095pEGdrF +2UQ4HfdghnKxWQK50iGUhCgBfqeI3O3cfi76ZdeJYM+7CluGNb/0sybjF6kNiAME +m5PfaSXk7A+a/FteFThW52E8W8Sekf2/lOMdbdQa26/oUfcMWzBj+aMcJBwcOaq4 +lIY6IPHySQIakLGCLLOkYHAG+Kp8AldjcwfpOZ3Jk1HrjOmx9CfonXvdVQmS2BQZ +8+V2ECd0uw9EbD+i4VIIHy6H1a57W9gikshXsv4K5vQsl0s6GjbioN1JFFC78XKS +XohDMDmR2Ty3LU9TLoS9K2fLcgtoJmnEtJ1cs5Cw9+T1s+ILFgoBTXzePnDKK78T +4uNw7a8CRAKW++dHtwHEnHOIDJ0rx+4Y+V7e5Cr0nT4Idv5P9xe9knTghb34vwBw +SBfEn0sCQoly4DGsKlPz8xhLRCX7euXsbPcTy3owpTFywJsfjR5e/jtxa6C5NmNI +LmGJb6TpsAl9mULfSRlGjynqU9T0EzOdcbPs8z1cLFQl7QRi63tlZ9jWh+7eV+dR +NaN6f0jY0me0D7OzvoD19e3ESFARV7MGQ5U0OaZOAcLdx3CYjs777AQ1S2q6ra+p +gr4oqenWqYkbY8/z8AALiWPO59Rl00GcUJqwYXlJANCtK4ikwQPG2+YIYrclBW/d +ZQplHShy0AayYPguLI9ts0XLulIrcsJ0zlEDPf3b8+Gr6yONiYpOtA0ZtwE3w+Q5 +5byhoYoBQPtLXyLff31ozRs/MhJd8+gIIReKSE5sGMwbVX2ZfjWOXzDHp6+CQIKD +OhIfgnyG6tPQ2N4DhSrE/cEITPlSOv55NUnLQUCgfAHvAslgWwmVDk1ikznij/Zj +-----END RSA PRIVATE KEY----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt new file mode 100644 index 00000000000..18221208c16 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID1zCCAr+gAwIBAgIJALnUl/KSS74pMA0GCSqGSIb3DQEBCwUAMEoxDDAKBgNV +BAoTA29yZzEWMBQGA1UECxMNZWxhc3RpY3NlYXJjaDEiMCAGA1UEAxMZRWxhc3Rp +Y3NlYXJjaCBUZXN0IENsaWVudDAeFw0xNTA5MjMxODUyNTVaFw0xOTA5MjIxODUy +NTVaMEoxDDAKBgNVBAoTA29yZzEWMBQGA1UECxMNZWxhc3RpY3NlYXJjaDEiMCAG +A1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAMKm+P6vDAff0c6BWKGdhnYoNl9HijLIgfU3d9CQcqKt +wT+yUW3DPSVjIfaLmDIGj6Hl8jTHWPB7ZP4fzhrPi6m4qlRGclJMECBuNASZFiPD +tEDv3msoeqOKQet6n7PZvgpWM7hxYZO4P1aMKJtRsFAdvBAdZUnv0spR5G4UZTHz +SKmMeanIKFkLaD0XVKiLQu9/z9M6roDQeAEoCJ/8JsanG8ih2ymfPHIZuNyYIOrV +ekHN2zU6bnVn8/PCeZSjS6h5xYw+Jl5gzGI/n+F5CZ+THoH8pM4pGp6xRVzpiH12 +gvERGwgSIDXdn/+uZZj+4lE7n2ENRSOt5KcOGG99r60CAwEAAaOBvzCBvDAJBgNV +HRMEAjAAMB0GA1UdDgQWBBSSFhBXNp7AaNrHdlgCV0mCEzt7ajCBjwYDVR0RBIGH +MIGEgglsb2NhbGhvc3SCFWxvY2FsaG9zdC5sb2NhbGRvbWFpboIKbG9jYWxob3N0 +NIIXbG9jYWxob3N0NC5sb2NhbGRvbWFpbjSCCmxvY2FsaG9zdDaCF2xvY2FsaG9z +dDYubG9jYWxkb21haW42hwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMA0GCSqGSIb3 +DQEBCwUAA4IBAQANvAkddfLxn4/BCY4LY/1ET3d7ZRldjFTyjjHRYJ3CYBXWVahM +skLxIcFNca8YjKfXoX8mcK+NQK/dAbGHXqk76yMlkrKjh1OQiZ1YAX5ryYerGrZ9 +9N3E9wnbn72bW3iumoLlqmTWlHEpMI0Ql6J75BQLTgKHxCPupVA5sTbWkKwGjXXA +i84rUlzhDJOR8jk3/7ct0iZO8Hk6AWMcNix5Wka3IDGUXuEVevYRlxgVyCxcnZWC +7JWREpar5aIPQFkY6VCEglxwUyXbHZw5T/u6XaKKnS7gz8RiwRh68ddSQJeEHi5e +4onUD7bOCJgfsiUwdiCkDbfN9Yum8OIpmBRs +-----END CERTIFICATE----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.jks new file mode 100644 index 0000000000000000000000000000000000000000..d6dc21c1bd5ff4a248bfba5a171518cd649e278d GIT binary patch literal 3358 zcmdUxcTiLL7RPgw&_WA@Dgpr%0Ra2t|Qzqj*?h2U!6qpaA9r02UCG0-ZeoW^;$= z+VdV+;l3t{Je2F^&mzpV-Ik55-yc4+k?XPK74>5FEv@hI#YMj$eD{OMwLP6Xrpd6| z{K$HxQI)Ou(iWbPC+jt6?CQRb5*)aEfGniRI5FqcLHiQ;p}o(jZ|7`6aNfJpe13!k zCh7E`_Y&L)^3WAuS~wb)`b`lJNt|enT>{qi$;!lIjE|g3$7jVDsW_IQptJ4P zL_KSa{2N0Jo2a72upU2=xfl{80=FZCD7r1Ku3?_azxk;M5RFzjs_ zKf_4kUTx2YVRdXErDb5s1{7=fY2m5W~TP+I*SI_eDqkVFgr^#K@jnGp8M7_5B%id!j{Rv&0zj!Yy;vdaaEXaRK z3Yps5erJTjW`WDhK5+_Bg^lZ*JhHFtL&Ev+_n=EvycTOiJoKoHrJEbqjT3Y~`9*!N zAXfTHDe>tzYbk1m>yKNp%I5EoKuh3LB4BuxdYz1-ssS1NdTU_(g8ciq+SD-2ZQ0pz z(w#ktO)m4g<{~|xKN7B%NVRFXt=($KqN6oS2-CzB{pmOM{jS05_5y;w$U#8aSND=qq=4Q)zH9-M)(krDn_0B6!A2ffDf6 zs>-_VHI(yI-Q=9Y>n%IESBnAh?e|v&FmpY#K>oA4jKNz^W>yV&92Jvgx2o1@jS5z2 zHpH;V*6Qv_xdL;$(rmY5$EH>{mBfk#%GeK$Q_oHbrQU}P@M#zQ=j zQH$*F>*;VF(7G3_WU|N;`f&97%LF)%h0ze;TWAzar`HBTqn$Y(pQx}HeoB$H)tb5c z@fDh>j{u0pR#_c|0f8W+C<^2iiUMxRfq(%pm;>}^Fm*NAtWh4t&B~z=Wg4}?4FH@> z)jW>oLcv%er=c(egyiLh7D5U9@Hi3N1fq+#k2}tr;Npe5fR;uff5agOQKQ{)q%~8F zk;i^jW0Zt2H=0>qMHQ{3uA;7P&vY?NSLJv2AFV|Jq<3$HDfSQwz{~s#05C8G06?up z-xxG5wzn@|kZp6bqx|GFoJ?X>y2)QPul6N+<(0SSR$E?fJF*`qwSFT_h4p6c%&Jf4IkWAZsz2%8Za)J4=`tyO*nm3Iw8`U~bmy|kP zn>e{l%gU4D4RCS7Ps{yJEvG#M2k+{!mA3FwGBDtpfPnX4}KT>u9) zMS{Ft@Irpi-6|u;PuD~IC@Xwo?EFaeaq3P5A&v3gQitloZ6s4ZUCbjw3Za#QApi)- zCpV$U4JZy~=fn|EFbaec|6%e#g`fh-Lhv&hcbhMabotqW&-_F|=mcFvk#GKZ&j%$( zqsWmI4k8KXLcBoo_Mr&=VJiP>;YpWW+&w6;Kf-Dh;Xm!&IcmF-G`u~%hK4cc zHyX~I;@uChyT{CNW%d{VaW`;?`>w7~Z?XS?d|B4LC%su?@El+t=JUlfoXj*{N0vz2gvs8EzQ>8JSSjHOf+kE52K`Y01 zTq#Mb7|oqprG8n9&jH#1Zm))7fW2`o5`F93JHfzpzElyxZbirJ+mwadN&I(yp2_3Y zvlIDrGLqtW<<$OB@hl8>>+#vV*lgv=-geg(k-(K#R(h$C63XY^#|-j5e8HY3S-l_S zhb-W(eg5@E(dYN_X#zy%0f9m6KW;%DBs}4_JCOR_KiOw;4;f&xU;l6R>mCs`r&ONx z{N*rFrvD@RNR-5H>2fxDP27Oh^%h8T9@ni&m9mJW&;uoeU>%0o^0cU~5ps&#;HpeGr z1)J{oIek+S1e(apV@r#QO5GvFwWC*;yUt7ZGb#=7DsoZZ1e$a{LV6RVVm`k&t5UeR z8S@w-E{>Y`N>7L908h#7A-!?&u50S{c~PIy4f2T8J8uXR z?ep@F0-mM0&6i8m(CxA%ikmnCJAG18H{xiYCpapAw^{ur0-gTx!(4v%fmh{uN81bIz2 zcKv^F-`y$dv#l|H+2d?fvUGXI!6<}_%zTluTj;RqZC7{1F>9}xh!+DKEfXmh$90y< zgbKt+Xvr3C47R~I-J$-Whrc8^&UjYtSn%Fj<37$Ts9i*8PV=&v%wtuOtQ$+_I|s|x zkzTetw4lVU7S$t}f*Es_1Th_WNoZPPhF#v_xs=UBi`k>N&d79o1;dDE60{4X=_jQV zgko%{%CLO%#(=KmbIk>F{#aoF-h!qdmlIrlw^RV1W^^QE6s_ginyl|6j z9o8)(pZvO`ueni>;*0New^Q?*Ho3G@+opogGU&Ok?WxK&erQl-B5X4cc%7(>Dy!g~ ZL>oJOr20!OUT)aV(#sM_Gi@+F_b&|~n(_bu literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.p12 new file mode 100644 index 0000000000000000000000000000000000000000..cbe7195f285b176f72cdc444a73eee2284d5d7a7 GIT binary patch literal 2666 zcmY+^cQ_k*7YFbpl91RMqm-7GQgIutEo#JSn^3D!dzBVdvo;l*MC%&0ONl)iBW4w~ zSB=`OTNky9)Yfv{=Xu}v-uI8+`JLx`&U60!pa^h#5ReWYZ2NJ`^-RkU^W5H z4<^9RpT(Rg0=VFx5j2|sPC1JbK|sLSNBU<1L|uTw|8s!}2t~1g8LZDg%5Gnn^a6nx z0M7|vE8kk}dMmFMpO6aoKinaVwT}a#=P%6WbmtZ3meW2fqy)mnCz6iAqoYmdeJ^1r zfvn*H8w*)K%OO!M%`oTiW`Q0*@=h&F93hDb)cUk1Q0tBK8=Iypq*b=&cKdr+7fpJ+ z;9RLvV?O5TtGMfmLaROVG9So0y}VV697SJR4SgHAVoK6_nV7B~AG$KgzxS_+HEL~Gt4(}Y&0PoX?E~UxRY1*H zzS!Yq!^WzlR@Y@UT)p(G)LG0}0% z5af=N%6Es~(E7Hi71?p2Z9Ia-Lr-~%hv(13*UMS${Tt4%s@hP4ht^R2iK7MN07Vf3$a1$Yzs;Tr-;6h?= zqMBImbpmHuE^-<kUZc?NA* zVM!!9O!ki)qbsk4L0&n=-=HJ6Ntu>^^6)@dvPD-RV+~Ej`rVG$K}YfLJayJJKJ6KJ zoPWkL#;Hr>L5QP*G=5xDYx(4+rp>oW6%1Ctz%HE5uM6MrzDpU^_iS+APtc$=T^yn} z#>u8ZRWI9FnS>@wO_0=Y;uZ`5>)Sl-0Sn7uL;rceBV{PX&+zJd@2od8%ZGF-%)++W z%L?t+ryrR|28gw6r?S~5Uuu7bAY~IEcrXECa2D&Hy}MAx z|MCO}g3cWKeg@d;|EWdyw_0Jhtle!DT?_wK3rqlaZ{9DWv=^yB?N@u|REo<(IzN-8 z?iclaH2Td2s84TVD@pmqJ{-M)RWs?eMTeNDygUjTRe0AOd5kzp2;e~<_xj`a z>Q4czUttT5a?@$O0tdh6HS*cC($TFcOC76sGFO7?88^SUjHj~ctGbr7@$0wTP>7`9 z>%U1n$m^MGG2*9r4bR>09$?{#_~2;3YC@F?!MM?%e&36f8&rra-Eq#UCRIim3v@nZ zj)>*9t&>=13d7v+F6JP^`Yp`ogE{4=QOCmWt;p9A6GP*~;MY13tvBVru*O#koH$77 znr=lmpAbrHY~krwCXCpK^c~rSkZZmy5hYvh3YoH9ed~7R!sWN>FpNuIoU2`;Rf&M&r>cU% zJ}U26U;f_H!eFH) zv~d|IIKv*XF%AD!7H!TRKf-=g}Te+R!XceD9C>RC9!mb$;! zU~Zr5x<#vG9p}awH>DhL8!Vb`0%t{hMgohMep<1UVZV1sNf3%=?n^`k*HdG53A26_ z@g@5J5buF(NO+C6=;fQNC6t~-;QfO(L?=!30-o^*cbh-Xr>PeNofj&5a~H>cOX$r@>yXu$ z<;@KhxzjNvrBr4XqrkGO^d+W)8c7@r=qFWbiC;zY5?mr@YPXzfU_bimpu;pYwr=5- zLcrU_5OA;SfT;=>JQ~{1i8%?HP&mZDyj-}sVeZe{t(&g%e04c+3Z5i4A?LJ~L0n2N z-CNP2b{?&$ehwj_EWASM^EtjPLOp+|6hP_Geo@m>_VN+Lh z&1nZa7wJntn8Brxb426hXuOmB^OfV^1s-V*?bP^9(se4wBGP9cBT2uL=SHzpBLq+^ zNJeRY0$+;FV*9N=hMG1Eu<`q*%#R$&4_TGC1uT;{?0}`J??S_=9acwrw^fUgS$1J;GIRP>$ca>`72(R8x%TW1;Bu zO5wMy@t`_-jTy;??pJhb>I)^A5`vGs%=|N2U!lj8LbeYXDGv3KdN5O_vA4ul2EQ8R zTxDm$wec|J`N4^KcS`#A^DZ2<8=tu3Wshp#0G0Q9R|#hR?C>+ L-q&3BH>H08J7en% literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem new file mode 100644 index 00000000000..7268c55dba9 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,C98A45E4AFC263C2 + +wLuUEXldYc54r4ryWd6jw6UMGYwn6+ibGKHp4sD92l42lmI2UrCT/Mb/E0O+KMMy +pHgc5/dBWkXgMiqDyLIhHk4kgT40rdw5W5lZkAA4Qt/Yzd+rbscTvzp09zrF6Fll +czgoE7FrvhOKiEOakerTit4pIPYosdX606cpVQE2lq9oZs9HVMcLzdAZj8A/P/4g +fo4X3+zqVYC/LH4n00bhNoeeej2o1lEJ+l9u9hptT2ATXle6pANa83Ldg4OxJyj8 +dkR9ahnAMCvYTSjEU7nwmGNPeFX0PIUjJKQivr410cYG104DC30Yy+XrIUfjTVUi +agwlMpHoBq79/ZRUJR3xPLkIGgw4g+RPt45D9eKsEsV4vqy8SFlgaoJ2mKUKleZy +i7D9ouzMKQ3sYE4eQVQ5o3K8ZPn5eozCwCVIp7jGSsuvDpLA9peZSwWPfc5y8JFD +/64usCt1J8Mv/e9NVllC8ZA+ZmDitTiwLZysczpMOaFqqeUbk9EJst38n4nBzRV2 +quxvg9W/iveQIydFyftCtNfRkpbp0NCsLz293dBYwZacHsPcY27IBCwXHiICjiAW +q7bnisXsgSaQMhMNRGW9YElZGb7ZWxoIzcyNBisGI8zxn48ObERVOmkOFxY/gs9T +YmpVMliWtmRG6hb6iCh9b7z8THRquxgTGE9ZFBwtLUKg33aubtgAfnUh/Xq2Ue5K +l+ZCqDGEi/FSIjVENUNNntAx/vXeNPbkoGLb/HSJwAh+sjpaLGQ54xixCtE9l3NY +o2QAiZ804KLPaGtbbOv7wPumxQ+8mxG5FN0hTRrsMW9t8pBXw47iMy/T2H21TD5D +E5XbM6kFeBrnsWnZJ2/ieXqDE4SX0tm3WEvZlDg7N7jV8QDM/D3Xdkb/sqJRabMG +tQRgwkLiB+mZ5MAfGLogI2/lOEayrBVz4qYdXojewxY4LtaZ5HiUIlyA9CJelMvD +nS52I6+FpaFhvuZC10qaM9Ph9TNyx+XKRUsPILuDiBRnYiHUKs1qASl5tjn2yyjM +71WSo7A7btOckzhDZdMVf1T472f0LGsRYoQebMhotqCuR7yArZHzTeWB0CjL3tOz +j3QlhKt2E1jx43bSK5tBasd9Bpmn2onvdwu1RRP8cyQBsXJSDy4/8t/g63+C3wod +8VPrlKhK+TenK9EoEqJ2mNuNq+duOjTXfK/7GM5s0BFKv+i2ckpDi1NPckd2gXjF +yUFZhmK6k0WC4jjWloMt+WQpi1rXMEXwCypgTrqWbvD0p6+X3uQmP57L4yHQcZoW +Qcs5GnihJ0DIhw9vYDhBhNo0WY1oBO20nVCN3R/JIpp3uDtg64WvfvMSXzJIPBCY +s+/GM5TtuD6mERDu3+qXxWwiy4PMQRcgjRTMEZ3A4Iv77YfQRkcd6S9qjUUuR/5D +xs+J4ryb1biz9ofW7I+Dbz4SArWSgwcuh14AV9RBv6Rh9m83rjT2K0yvbe/+7hHW +R8nzRMqJcGNGCHmRjA/cwoiv6+k2J/RbCJqnR3RmNex/85XaXBfZwRfHXVbzZQfa +SrFaaNLf1hMwGLAJjIcQRxa3yZbjFXVx1Bp4hh8rKNWaOItjavNtNg== +-----END RSA PRIVATE KEY----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt new file mode 100644 index 00000000000..47e5b37c28b --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDhzCCAm+gAwIBAgIJAMDqQhbo/w/YMA0GCSqGSIb3DQEBCwUAMCIxIDAeBgNV +BAMTF3Rlc3Rub2RlLWNsaWVudC1wcm9maWxlMB4XDTE1MDkyMzE4NTI1NloXDTE5 +MDkyMjE4NTI1NlowIjEgMB4GA1UEAxMXdGVzdG5vZGUtY2xpZW50LXByb2ZpbGUw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDh9VWS5kI7Sf1tJSCP3F+l +F1Ve2w9GgoRYjOz7jTWm8h8WPoMSGoCIEQqxm+Eo+AGCd58tacKO4ANxZbjh33hP +7bh7jYmj3qDZlwnTaM4RIvzPSgYzlgx7iBWXJZoxWi9jlEBehg/bB6+2tK0/4CJJ +27Xi2cjJDTcctyLEhuQEH6oLf0pBfK2UXv9LkoOkrnRzY+x4YBOlrPmho+5jU2iw +5DnFNKw4Cxdd9XnDpAprU2E02pCXN3mpcvDk2MdnzWvDh14j1eisxmAl7wbU5fdF +P50v5m8cOPreWUlS2WYIJ+nHLnbnmVE8F2FpXDupF5WK5BU/QHVnE6i5kwvMITsJ +AgMBAAGjgb8wgbwwCQYDVR0TBAIwADAdBgNVHQ4EFgQU08G5lM8hL/8f61uAkl3n +vJzyEv4wgY8GA1UdEQSBhzCBhIIJbG9jYWxob3N0ghVsb2NhbGhvc3QubG9jYWxk +b21haW6CCmxvY2FsaG9zdDSCF2xvY2FsaG9zdDQubG9jYWxkb21haW40ggpsb2Nh +bGhvc3Q2ghdsb2NhbGhvc3Q2LmxvY2FsZG9tYWluNocEfwAAAYcQAAAAAAAAAAAA +AAAAAAAAATANBgkqhkiG9w0BAQsFAAOCAQEAq84Eku8yLOcaxfBb7pHWaHHsaxXZ +k1lK3SZm49VTuwtMrGCYY7TBt4Kz1mnpQZd9KVyE4BzhpvUmD2ybSsyK/w1nYGVw +VyFEnutlIsYWs4rWwrvYoX1/B86WvNMBa+XFBnlO0HR5yTc/m5LKkNsZ3p2CGPfN +PCaok0NwS7cKIsWIgBaFlIYMYjZM+cL5qAWeOOgQoxPKi5uzZ/YqJbWf0jwpA/8s +M9QuqJzJMSGvwn0i74ulbubjnit2dMbrUUm6W65snw5qLDSqZzDH02EYYG4yMkmP +/S/SZFvw7fuOHFeJBoO3oej+ilEuYPkjkysr3Ys6xmprqExdDHUMElEycA== +-----END CERTIFICATE----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.jks new file mode 100644 index 0000000000000000000000000000000000000000..aed185d975567747a68499cd4db558dc43dfb35e GIT binary patch literal 3239 zcmdUxc{CLI7r%hfw0i~*P&qW{mR~;4a=@Z7iM|4Wzm+uln>>*Pp?41vH zKj7Q!>U(Efw>w(@*z-#19TVWtm|=kApwQ2AC{Mdj&i?S6qs|9hl@Epve3RIXQ}PWT z9aPI0RGSLoJK{h#NqIpv#XEm~l9UL_Hk7K)nTb0Td3|;9p@>o~ExzrIy~~*D!>H^;*qJ^(v!J3Djvgt3Tw_3kL8l4OS>EgX@LhVCLiYI!S}blV z5 znDWSU{q{+0RX-)K?)$KriA2r6*|tf^(HUXCvjJ`tW2%l-CD3qX`T}y9>qw>>Rt&r6s&vEI8Yhc>D-wx zrMa!1`%F+qJX57PR07ludZ_&g>WVivbwuoJdEV~f;m|vv9G_Xb+_-sjO6&d#j)!g| z`W)H%oK|e>C|T1lDs9%ZlsI&1xd$#$BXH6DIW^V%X_dgG@DN>fpA0?yvErk=2{$>C zaJQX`DjFw*nB(`-4GY}8NSAmI4=MRItwk_5?%lZ2*JeHw=cdxLhV>-r(nsg~hI^Sr z`mw+Zt>P~e+b*518na$0)1JTi*@EhuXY___ z{3E>Stk}D=%!q>}Nb%AKw*=$;PV;DwoI=>npNotm6pUuZf_+=Rv71s zuBW;mYJ7w4|Ne#+0KND0AuH`tzj|_T2*yT2hy0a0-8n6v*f3yUt9nC^aZR-URO)y_ zJfBqdYDedLu0v>z%#6OhehCDyU6nt9Rs{gSp=b&?2u%TzQotY}2m}Sxe9{t{W%2Z* zx!Iw|1J4G2=LP~f*#KxHMhq>=4!#Tl3;bE5MT^3@F?((ml`twN6i+Cd?y0JKs^YKe z-||5LB7b~(uRnt+Kpp^^0)&AmKporT1qam_e_1)(MVL7CW)wQ4qwAv9I)k(o@&U#BAMN@~b;4KvT{JoJmwP@4IS5S-pg@TvYb&BX>5eN!@HbKZUlM`jY~|oW zf&F%jrNDoef3(5=V5Izmk@Am5%0Up{y?P7c-K)AE7x2d%@0HhHj)8#ZZ4la`B5LN) z+a1nC3b7aCCie#)Q^E# zD5W0xoCF3&ys*w2xfq)1GCh$b>+ae(Z-lEfDGDpii)_%9fdA} z+0w#RgosH9yMKA=>@L+v-f}}CT2^)_^ruEgryPUpTy9+aMvAxg0t5ma{AG&yb%6O_ zbIkEazr!232k#!hpgaG8w?BD{rRl+Y^$*cSAH^WiV*iHs&;9=aU+jP5i#7e5Uj7Q; z4?NZeC;bS`@0rjFC|xT`_@eOe_vL7E2*&>io<4l6VK*%#a`nNSa8tgy2fgRO<4j{V z-`1ap1kajRg};<@pi4c=h>AFma&y-TlwV||3p=(qx>D5;GuECq$YxZAGX1UW|IZ9~yMFl3W7DX7B z2%dM4<>x?5KOBD1XXn3a3YOo*KROjwIj2PiKZDB#g+*V^bSl^F<8)Y`i#i9)4f;!f z?Ez#qw)~a`)tST+w&e9wXLN&i{yzZDWxmp$wsU*&RJ<}=SRWi!GxAIg@wvKSd0?J> zC{bTjZ5&4o)#WE6I^vZ}WJUw#-uX`aw36#Y*T0gP>o;;VwL%Z3&s92qH|!~){rV9- zFD<&3-VM%Nxt~^j?_Wjr4e?FTbck*=eKQByYY1%QBM3N`h++jl#mcln@&{<#{HD;k7^s%AeS~x}-lWbTA{HUHglNiM r9k8~Q?mki=76KEFvF(thzUyH<%;bDLr$c;ip#6sK_nhMyRCeH>!kvKv literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.p12 new file mode 100644 index 0000000000000000000000000000000000000000..111d6a79f9b0ecd531577a4b2aa7a2c44619fe88 GIT binary patch literal 2636 zcmY+^c{mj69tZHj%rIjuyF+G@bp|t(Wrh(s);h9gmt~N#bI{la**lRfOBqY3P%uImO$MTWc%jC%GkDz zb7N*^1H_PkGVIjJ7S`2TC&X=9&JB3!i(r&<+9KpgWB70ZUZ$O!KIHkj#3tJI4D~RR zj?BB)yBw?7dnF~ytOsr#v%ZPG;3d@34W9_uZ!8}u#SaJRzOhhqt(8s9igz}iv`V$` z94Yx)wmXy67ub=jZTfUbe<)3MbHz7~C2CrFzr*WN*1_ zzNZ=B5$2%^uyn0(%=S)VXdh?dV^X9dpHhz}542c~!r8zhBS_;_yx_CoAN&@2X>x zFe*#T$r4LAnp2CS_Qzejt8qIro6U1)H6AEF=~*{2wyIkkr^U8WUR!S;Y?Vf9fF%6N zcn%0va=l{i2e^jTkT&DSDxKci3b55%qu-ab0D*Vu!gt^4uNYnL~cvbL2V?Gnb(t!ZkR1zF(QbI2Jw!sOPO$nTfm{HX2$iq^vF zCPp^gx^cQXL$_?_C(zfuV%=X<4%3p|RBF>{1`}AL%%yf3c6f=+hLg94VvVzanQLzr1YO5Zt zxFeiSpuvvsUn%O@c~_%Z`;_7xV}v>;j!w?M5@~EG2kU7k4OjDy7XpOCVf5`%Lq6FE zssrIl<*%_S=5*xVu^w@U#S-Geot6yjC5GSMXAC;MU$7qBe6%A;YF3NL9Rq)3C<>^A z#?1a$=W6jWebNx`w)~U-T>Rvr@$L|wU=#ix?}`_aPJNK7#h1|~*JgB9*~=p1$sr~y zTxbn}=X>{lokz2Zrf99%8xeoaaeP_uVegi)5anmx;<&dA@0+;VwHNS_hRWvUHU*7%6bMk>Mj0wU8@k&R{= zn0jZWsZ>;4RG);&O`ji0%aYBE2iv*s;sV--Oehj4=6_%*CV>KgB#_T(eCzb!!R-HG z2Fk>I>e2QoL>vF756j>BaHY6JSRWMP|JDac0=}^TC(@Dh8+A&5=6u4MvrNTVQF@sd zN?8Nzkg1zHt0Um~`*A9CFOfpt`8P$*`$AunMXs1$_=Q|xbK<%68!*ZQ*MIG9e+kjz zvsK43ZhK~MiMN(Av(%~v<#V<1RFiR<0i{@1_!Ovky}pd_$jh;2b7}8?&Fe7T9Vs4T znCGaPyx>FI7nz-EzhV0}X}onmr&!GewD;_iGO=uv4fK|M*UXOKF2(_lV6pWZr#tQy zvS%1)Zwgzcq>#TfIwmTGdvn;Z!IttN#zXz7#_wcb)ha|V>{=a#U4fomjWJc=pma}X zi};)2sZ;EttFXj87N~vFdCr2U`dkGkJ~J1uMF*(0djf$h5T8#PCGrh)Wu8|ucsz7KQu3AQdBMZdP4xnkKDj~MF{K%X7H9Tgc&t{F?S zx0=WFEWa!}`WX#b9Jcan4V%`1IF)00zi)w_QB|FmHpD8%b!CscSanDB@VnSeT9-ds zkgDC05sD!0AdJz&TB$fg|J>y5i0Ge=v^?BEVwoiSHsLx_J)F_`Qt+=YG{>-yBh^ss zZll&c?tGFdk~a9+9Ms&?w7nT_)kI70%mSn`Jqex7oi!VKI6Lq($(UQaeSG$dd-zke z`oO}9E=GUTpr*#<=ez#BKZ|D+wwiQbJw4JoX8cl4jMFcYz9U$Pp40b4ggs}w&ccOZ zyQy-xRkwLVy|wwV98ZeW^9_?S?uNM!WKxyAWh2xf0PA`Nn#IW`oAjht2wI-WpXi}C z%6A_*Joe(MB?DF`J#CPXQeoWnyN+9n`?IWz+y^S3AY2Y|qm^!lf*n4`X90x20EU#X z$DI=1RV7918yV;V-ELIFI}LZ|CQX5kMc=b~{FAP7FwcefDA=$2dyz@%(C{^KRKkz#L0897Pcq_%Ers6jexBNu!{8mfT_O8M{%d!&v-FM;2$7Zi&q^c(EK?G5Ii2=wMZQ(P>-o>9=NgZh3LJibT z@)H=*xF(nQ*q}2ph?1m#(O@=dzCNJQ!Vf3k?$3ZpQnCyG(6i?#-=uWfaC3-H`k}0E zARsG>b0%8s{nEvsX4lSjr^w^q%HW@vJ@XX0Fokd>T3~zzUut@lF*p?JGd)M;&#%K7 zAvK9cQkZw)oskRtCXJsSEqMeW4y%&y*)>Qr4bw)?$|wlFFfobc?;E&Y7ZIFSDUV;f z+=zBVN&Htw2tQf?$Vab#bw5mx&kM%L7~i-hf-DlkaIN5AX*Bo;L2Mi8la`LZjd)2pELmVqq2m0f2lY8ZApyk}|YC c6VtFLzxJb0yl4=}CdGVFO&;xx`y1JR0ZahQ#Q*>R literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem new file mode 100644 index 00000000000..4f5b0e56782 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-client-profile.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,AA1E05F81F24B5E3 + +Axn5ritl59GJQ4PLJDIk/IRvYSPsk+5JygqjZc4oeewhpbWqOjzVYROMD65DqN4k +sZw9vhDSm8TjhmuMWP+n1oJWZtAEKBcXbAhoG8lErsJPYx5xq9SYrbK6LWXYlVN2 +fbf5o77vQDqLiZf2QeXyufgLbEZ7yslYPBSMiOQfp2jwpHOQrlWIg7awheTpd8Dv +PQ/Jy45mGJ2gl5n1Yn+nZbIO/S+3Wy0AX0MmS7nBU4ogOkIMq4ZBFALnfmcdGZHJ +pfi2riNF6lTeMgHrGtCRY3yp9Hyu0Ve/2fYdfECcG2BUQ0TweZynMqE3kJokwwC6 +ua3T3WBnQws1MYxvYjy8WaSriuAfNvnu80rdiJRRcp8wBjbSYrxHq2BtYMrVuekt +lFdDCBAnmbTzYVFCez4K5l1Tbd0ilc7D8dFhHP07dkkcm57P2cm3u76O0pIqjzEx +DvYs33vdxiFq4Z4QPDbFh6Xz9uaDhy1gxlm8/giHd+JBPJlcoHD5C2Wtd0pI0tz/ +5n1bdFeejqItmfy45IFFrRn/jb7Q59olVNSbWH9RojLx9HQct4w6MScmv8n8J/r9 +PUrapSwwLEV6lYDBMsO5RXXDDUTJHcXVbr1nuU6BTCTTe1nMIK1+8pS1m4Cizjcg +9J3FWLktCqiCx8NI9O/QzIsbyA6R/NjmvYPOx0/nqtMCPNYJHuZyExMiVMMaPNly +Ic0HfnZyiwJPj52l67xzm4KwJH57piwldRGjVCj7IkVbHs2MRVsT0+j/QKGSU0uY +DTHIOSToCrzorh0j01fmG4zpMFkU/rtCmT3STkSFdsEsy9EORGx2C9t4mVth3V6e +Rc0y9TUcKGdtW13OiZN4o12aToC7yhg0aIpseWm8I0nnRg/TVtzoltOv85I0Lelr +vcQ8/jZ5Go8JZbTrMFmCdIPYvx+m7lL7kGx9Zt3hDpj+EBm0g5Gp44KUkxtI7Bs8 +1sUvSTyNKW8mixkiS4Bq4dGDqHIuvwW1x9PVoJODbHzTip5aAzJWmXA5rOxVp2kz +keA73TUpJo2UZkME8SiDGVlcnZAGx0odxe1tMBkc2GPpQVmz8Xmi75aEuvzBlAEh +2LWGnBhgN1T6cwvkJKgdbVHUlt3fUIPHzZhItMKrPbATMl5Rtf8Fkj4TYGvoxJZh +QPLuD7ngTORv84W0xnxlt2KO8hEkpKjTImu20n4FIb/YPlVxbYULnt9xRl/QaEol +7jjpZJ7zmuZBAEevOlQk/Jc05TbdttPoWU6zVsSswjuAn3lVRIK9Ad0iXzPDWkWU +Du41QXpkCXCoIdky1WZjmZPqLd/nnSdKSBt52ZtMimFix7uer/u9f+933lETSK7U +ImUFAP/pnlmCzll1Rmublb+WDyFV2lIZ2rZURIQUuQMCCcAFo9XmWgdTjJAOUdwX +qLvYUNIVb2B5uAUgm8Wn/vxUW04Jn1aQrPSPGBCo9KSy16DbkslSWpJeCHwS+FBP +Z8CedsnajbUnAa3HebykjlhOkob7wTCogzLjaPj07XYa/O2Dwmiv1GOnXrdie9Wi +ul0/CAm53ZtLOrgHmi1cPq9FtYAYJLboLu7eW2jZz2MjcugGG+0eGdzSoKSfWfOX +-----END RSA PRIVATE KEY----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-different-passwords.jks new file mode 100644 index 0000000000000000000000000000000000000000..cec32ed75a9302f55bd91a26f2076b031da66881 GIT binary patch literal 2339 zcmb_di8mB(8=V<5${=a1BYT#irm<%!MYg1|7n&GjvV^e{B4aCte3YFm*(xD1_AOLs zRED%zBRf$O!_4@p^PS)45BT15o^$TK?>*-^?|GhcU)Bn11pokm_6qp74hG=;1H1_? z_&ou=lcdfB03d8AB6t^dh#jiP4g>=gK)gU81OO(2mwHo@1s(dewVR8>Y5EIZB}Me^ zGmY_dbb}Z{DLHUH@@Q*U#wzs&d*h4K@#l7Wb50FUr8SVMF%Kk!$n<%nsCBt9Lt*B= zG~V*Jn)pe(2{FiV%gP5A%yTH68w&1v#fB#KqPu(*2*{g=93zrKav1ZTzHN{NquVle z$NIuKt_5vYM9A>w<71?O?qQD~y4_QJ2w!TdR`>u@DeYxCCU*SpuQd8Ylq1H>#`Z~` z>$V(sQHr4%oTH=1!j(lDAhvkFa)~Ylo@H zvxHOe#t*@kODEv5l+2*IeiWl{LN4RiHax$b-(=@FU1L{IW&D6rJtEs6wRT7Y!s+aM_g)3+_CSkJh;caQl^yqqq7mD_rA(mnS=qxTa7_?U((()8+fr8*|-GR+lme`-l9>n%7(PaR=z}uMMf)5suxY*B6rVOo!AaM@*DjLLn=7j9)GQS37});GTNP5%R=sEp z5qM4&h7Y$4d5w>}^;)kWURGE0c#^V9Hg#$9n+y&AJapBpb^u#aVAu0zr@(mTCul<~ zv@uOG{Alc8#E1@E^DK72qVg1W7J?FGl;aR=_ihBN3 z=OfaKNd3?(OUtdBzR1098c#ItEH7nJ&RO4;ty?d?UhtZ6DORmZcMdz{?s%dAN~o3 zm9nu}doInXFtO70-b4$u&Oiyb`O^JGt_1TN59L(5(7tE|hE__@V9?`!y1}DX@!vCW zn9lPRw*{Px!wM@>Duf&IeUxqH&Y9<+zy0Jv3X z*ZZ`R)6fk}`q9YuGi5nUsltu|0Aq9#9Zj-kR0{pY<}04(VE&YH1P;;X29VF$Aytt4=YzUJI5QhgYB~^ zxSfvnEI&z#JheIo5SVSvdC?!MtC_s&%14fDzs{c2#eLaxlCjxeXtm;HwnhunkZ*cB zA>k|kOE-NQH@CtQI+!5lQzhGC?~)l}s@$p9q4Ipl*?DD?9L*9@%l(AGgpA((ot{YQ z*8Nia`Bo{2HOo4*og>~+W(BbtY;$vc>pLP5DFp!fq?OvtYP+L2Q;Z!;R6yU z&ShD7T=*bAf&T;8yQ#*BN`uN%1C=W)m99!BMZth*D$Y2;W%(QNH;=;MAt%0-Fj~Bk z?S)BM{`ME|9JfyJ1KXq4zOJquKk@oj8Tm`_+Nr$myEz>SftgM|gv^O9vgPwHs^-KiQp*Gp z0FnP+i2RFO2wqrsZzA+xS(PaGKfK?gy3eG(&!oQJq#h5B-22Pp|7`I71KdC3y;a?t zF%a;&S2%#7KIY|(iA$BL%vOwpVWpQ!k**OV#t)p`Vfxm7v(c0xj?VEkk1_4lrvi^e z2uk9e+?wbX!z_p9dhZZ%5Xo>}UO)UO+3+1_F4!(QqM&2VRJuupAnOXrnR2igjq$s( zTNRe_s#E234uAGyHC{yfaCt;#O152*&SDxp<c* V!c$9ab#M(EM>I(7t=g*;tPb&a0fe;080C6%SWtl+)CC{V zf6=9mv8HC!$9mMalm)GUmfVeT*JoQj4BFSXrw50RSfcbO_;C1_Rl*ssta3FnOgAjz zQp`8wwg&!&?!HMx9qx0TkbZlU!_MV0N-U}6_6?%yZd^4+;S!Jd!1Gq;W>QG`A@g6e_*;wYgHt! zG8Ou>AJR@13rpWo{+IIwyk$B+Ah9PZ{KqYkONk2(jkxXmgd1Ph|3=@hut3F#Dey(ys%A-ENuw)lVLluRY)NIC#PTGhsrdY#E!HE*c>lv~EsQ&e3T8t};t%XBc ztdem}H6zJhJfl8m(F$SI=^$oy4rgdjY@El3)+>puJCL18x6aeUSPu`&c>dk?fmf$y zu6QKMFuEjlt>J9R2Q_%z#F$?pN=PT7c5TCInmYIg zu0tB@Tkoo*y&E)}xYT~zK~&{$JAFstPE>L1x-Rz2bdqSZ`2pjO1uBwQ{}2-#^kGLk zKc1&5S(i{m+>LmkEM+(IGERHGS!|KLdOS0^=C$IkTrJ}Zdq7G*s|^_u5}XjRt@&m{ zw;~)-Jb8$1OKYe3)g^$sI)nyRSdqZnmntB;Rr2sEDCH;U~|9S z`yG@0Lep5}O<1xsf1`lOct&;e8~g1oGr{wGeqOJTsBs7Voa>W*?wpC8_1~1(8g8y6 zYujC+tYwYYK8I=U|pwR&P4=PJCg$AGCC&YOYRs^vB0aP{zxW^mBV-cVZXsBoSOe?{E$?wPsfjSF{PNIDVZoUzjfbWPRzzO_xtC=)d}Vy zyiXS&4+`1!OgotQirtaejX+cngg0AB)TK;k(nmL%sV*CSUV-)9p188is1v#aPPFOL z9ZiF*EPC!E(jG96PAHt)w&S?B@1JJ%>c&6%Z=2R} zZizthzRKN=fy0JHCfE$Sd<}= zQyh3D2#;6AD?*BRg6%O>J%%d(ga5})6j0*#F^-iUP61B>5CufSC?E(-zKHBPeY?Vp zxz)U=tN}}U?F(&vXBWI=KdVW< z#UN%^S)>j_&8^N)94z)97>KLI$RoTKZ0*!t{d*Oo@l5T}8++AT@hl_WJ14*A+}DZk zc^?NPiB!268X{SXoHv+`bcs#f%oyXJ1@fX(nhJYL)`I2O_~{=eShBkdE917zQC+NB zImBMdJMYa^6Q!2)jvr=uq@4FGY9e$m{ozNqSex`EIYMw>sd~&47#sw^qN~sqi0yc1 z!aN8V1VF;SLQVu9f;R>om$*M4;W5?IKf&;IpB#^bMj`QEWiEsO#D5P#K7OqCP{#-L zyTN{^{P=Q?DF=b<4imIcr|?P7RIB767Os|{8y5v4KCfQkv*iUcdEV{fDvg>n?wY?c zjh8{$f7;QAs2vL=u1OWSa0>QuVhJn~>P}YqXxr#i^+@=#wccubw0DhN%M6J30dK{N zM38dMXgx7=S+25=b*wQJzeEjuZb@d8_$K(2>#qHr=Oz{4U(59(E$C#o@i#(pYYU~5 zpWGOj5z)-~unoQ+%2nyYW$7u5=D;DdZav(A7I7G$%|7Wa;Xlw@P93{OJcoCj(>fD& zHaslBO<(h-C=J`NAW_Rl<7qGPmlWNjK=gsXLRD?E5DpJw?| fpV@CTY3ZWxpFuROJPkteU~Hd%{Le&0vFd*T560dY literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert new file mode 100644 index 00000000000..ced9d81d96f --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.cert @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDTTCCAjWgAwIBAgIJALL7dwEsWamvMA0GCSqGSIb3DQEBCwUAME8xDDAKBgNV +BAoTA29yZzEWMBQGA1UECxMNZWxhc3RpY3NlYXJjaDEnMCUGA1UEAxMeRWxhc3Rp +Y3NlYXJjaCBUZXN0IE5vZGUgTm8gU0FOMB4XDTE0MTIxNjE5NTcyNloXDTE4MTIx +NTE5NTcyNlowTzEMMAoGA1UEChMDb3JnMRYwFAYDVQQLEw1lbGFzdGljc2VhcmNo +MScwJQYDVQQDEx5FbGFzdGljc2VhcmNoIFRlc3QgTm9kZSBObyBTQU4wggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCkIGS7A/V6TesR34ajMyNYL3tB1OjW +Raq4KtF8FfW1H6nHGrWa/qXjZWPirczy1k2n6ZL7YOCcv/YeY8xAqC9mGQxvEuqo +EaqXq2cjRdAs/7zqzRkdPPi3Jw/p/RHrDfOAzOsMnBGc0G2Hrsj//aP44vp85pek +fM3t2kNAYZWYCzXUqWAIUoxBDK4DcQdsN8H4KTMIwQEEiRtcKnL/b8QGKsyGLfLq +36ZABHZ4kY2SmcP3bWxZtbFN4hamdwoAtYe+lS0/ee8/fOTLyZ3Ey+X6EEmGO1lk +WR4XLli15k1L2HBzWGG7zwxVEC5r2h3Sx1njYh/Jq3khIdSvDbiMmM+VAgMBAAGj +LDAqMAkGA1UdEwQCMAAwHQYDVR0OBBYEFGm8wrYF9mJweJ1vloDw19e0PUuIMA0G +CSqGSIb3DQEBCwUAA4IBAQBbEZ73weDphNIcmvN25v6NIfjBebqgm0/2grDFwmZe +Z1DibzRoVfoQ7WeUqbPS7SHUQ+KzIN1GdfHXhW9r6mmLbtzPv90Q/8zBcNv5HNZZ +YK+T2r9hoAWEY6nB1fiOJ4udkFMYfAi6LiSxave4IPWp/WIqd0IWtPtkPl+MmG41 +TfRom8TnO+o+VsjgDkY5Q1JDsNQKy1BrtxzIZyz7d1zYKTQ+HXZ4yeYJoVoc3k4y +6w9eX2zAUZ6Z3d4an6CLr6Hew9Dj2VX1vqCj1a5/VvHZVyVxyh4hg8sHYm7tZOJX +wN3B5GcKwbbFjaMVBLaMlP62OdGg7tCh61evWm+l06S0 +-----END CERTIFICATE----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks new file mode 100644 index 0000000000000000000000000000000000000000..ec482775bd055647acc6297c5368a74ad8388c70 GIT binary patch literal 6284 zcmdUz2T+q;y2lBG-a(oa14xzfCiLD_dau$+1f+y6O@WAjbV2Ee^xk_>dKHl-s1#|U zfK;Uj2pe$sTRvy^emi$|=FZJblJlJR8}hcjBLV{hqJyHYz!gmenGysoBHW{yR9s&?UhUq7)3Lp@7Z z$P)NU5n+IeoPX&P^HbHh2RUUP?lxb&Eh%$Leq?5E*y!3-EQxgsmWUG4nC<#><`6jO zS_yuLO%(AdblX~b*K7OQp)=H+_3f9E9!s`OobgZlN;2vE%SZ;%!&zfxo%gr#I97W3 zygnyuOVU``n@SYYJPlu>l9Bbar7UQSCmdv!z{kV_VSuuOT7jSz03W>{jFezZ00Uq= zYm$Je!I#F`8=t&k=0Cl%b}KN>>~l-n4#f!&6mxc+92^u11O=n;9g#Lxj&?|Q4;0lO zO}_IM9O-0b?~Ee&qgxO~^UwChF@hHc311i_d~uL)C^!I}bfIMEw7mENUEE`IdZG6i zgi$;Mj@yLse7@Yhb!+4Cgq`bG2dek+#ws)Hw-?{)HWR9qSSH!jwAZ7mC+t_`67O-D z2G23f=k2nSI;N@&hMyAKS|VHwnH8U{Ay|5-tHUQcn%`yK3&0&pXc+@JeCo#W(HQpd z=@*enjT?xaqMJ=e(eA&NWG{$Ua8a!%VCfDEq<;7$gveT0?MKIt0_Bo6qtGYy7oqGZErFcN_}T%!oXRD70ZN z=oNM3hO>pNDC9?n)yXXvWvRhs*u5eES%@K1mQhu|6x2n^!JBnP1>0i(bx zOEsT+?nb1Gc|O8vl`Pk_FSPShup&cZ9O$XCk)V;{D7D7nO-Ija zkw{oOQ%2LVtrkP<#PgV*5@M5qkh`O1ufq`*lM^%D^1RV+K%Em)xbQ@AoP}Dj%<#Hh z<1BLuD)gbUD)!eGYG09g$}`6lTRJym$iMKCh;N+qjXPK^NnVb=8jXF@xwFNO{C=oh zw9d0jm(qCZTy5LsvQNz|#|U?7EIdeL&#UpFZ90}BP;CijX|u%l1je%xHrEFlhdP%g zo#8vyMfY7qy}KFn)rdRVSD^|)op-Tl4cvPa?#ct zF%wcf8*Wt3!0FxnJ|SRlD2Dz=bH1R6fZ~9RBF?nAKc88qD5Z0YGWM5E!9NYscPIAaLSKIPlnzn}VuDEzo#k;vKadxP!)nK^mzig(?5i{@o5aT!ch(bqnQb;Z?;$CG9Jilz?2GG#1N z@EYE|%6pwJx7X%QYOe=r-vu(M6F>NWOw8$Hclom7gDr=6T?V)NCA6CL;(Y)+Ns+En4gbI*8YZP6)I zTaD^L>-fMmz+P`N+r^8g)S(T+6vNaqQPypijk%BOe{~^=9sZ^6X8-Wk%y9LvDe;dl zD)$(<*|%QwZu+1?;@P)+WnUTy(pKI`>gX9ViU*Z$ocfo36Ps4+j46n{CL%wTYr#G$>DA)J{K3^Dg3EhxhhvcS3b`y)M6^mE&9B5tn;MQ{%z419K9JnyUvtdh#q$1GS11}>dNgp|YxM=N&^dmDFzm79$nlmlQp>&K#GQo7g=(L<{$hz43#p+6wH zavJA?M-U2w3PZ(&L}2HFM-&|j{XP8eFZfsLC#@h8&UnBn*k}be$#P26J{$)a` zsDXRLpK7=EN@4Hi+LV*rMTE^l>EOk>y-k>mHNMplkvEZ8{<(#cBb0QDU(z ztI{yfY0K(sI!4KZdJfW+pX6)A-vS5Mh|~&=OB4QjVw$%N5sAr2T+P0IwYcenfA|?RJXn!r>ka;oVvNm?sPN@_rl@m)yDU zCMw$>WBy6{@2>bzNMoMd(Ya%I~|!2xHUOh zBc&SlTauhBkz3@?_S@%Hf=3xrzIiR5L@^(<`!qdI)!ai>ba&h~x7Aue3fk!(lC9f5 zDXbn{XC7BrsD{j3_uQU*h;&%Bk8qxT(>g|mS1_O}Po z91-cUy0rdyO?+1?@9Z}~b_;)6bKjMxt~r8BTSO)~3#os%OYQnBu_|rQH%D?^OhHGX zVw~WWmP0*5pDoYPUDJ15g3^p$-u=t?nI;Ug8n87|a|_2d?Ptj|vzIfTN0evIb`CGT z*WZ2lJo{}~fWh{ALpIj|CgumPaIKx!;R}XsGwn;Z1nqU*QQ1`By2vLdbz&pWH-E3T{6Z@2Xy8aYxP%CjgSip#ru3HPPcBM;OAlxvH5R4trd$ZGif+>(Sw z$7YYIQH(Tut(|-;BOmC$uj;@MH&sc#T~)}-+ECbSFbE?{*M+~o+g=*nDo)xY&Ht+N zIJf?&>u3en2qowKpebTi6PGnIn_F$A!EZuwDW{x7?J(oOJ0@Qx{2_Jbil{V{|UkQ}WAAg!$_PCd? z)R~EC>9plqztLW*ni|7cgeMJiV2FRrx#O@I)+&y1vCF#5O}0+5~slpxS47#qMse_c2R1rgB8rz`8i)AEUK zUmtr?Bq7qticTE-bIptrp#q)FfbmNu;LAqVM>n2fj6lDSMMf^A3YA z0Ulo+v}hWfjpXA>*NSh`fO9T|0Y9*4Nrt&MsVhmz3j z8jAIj^Db5}YPGlCZtfKYsp1N8GI^*qf8TgzieqUcym>ioHn`26#|v+2D{RCtS44M# z|I&xP61$9sP?<;63Ugdm&(d6WhD(A5rc-6)bt|GiF{tRN7_UY&-G&bBSm2I+bT_F9 zlWeV@g}> zrLA18?ssGUp+|vj4}UoO(7!vDlI48ibq+tl8EU`G12p|;(*S7sxAfy#|k#HqgI z`t5cCD*s`@WdR_+@TL0~1y|wR!uZWx5c;#ZAY}4iUF)xK?8rMfDJR1HI5HGul$jpl z#VKrYBOKNjv@3FVIMywzv|Xl3+o@BE&4zg|A_;~Qllf^!u-9nI4}NlG=<=J0!iFNf z>ux$~WDsXTa56P(XN~OUtOKWScDUS{Z$|a|mjng^4X#%44KfCioT=IsT8u4Zj0ok; z(E;rx=Sv9ax0{8LK81ap#)NiKGC44hrL0Zcp1m+J^A!~nNwUDl5TVj z(@Bukx4v?(r-a0vJ#D{z>+pG!tyx7lq42XdyAQoyMwo`m zC`t*xJO4jS2;vreM$et?jF@)(XhNHxikf%*5OijddOOk35zF)rOR5R|0<|jnZRU1$ z*K*p({K?D!c9-%f+431sWvF?f#2PDGTvc|cZtSCUBhY<^{?Ovfb@#r{bnW9$WxPne z0^q7;!jzmvc|M4TEQq& z7hSd~#xya_qb9Sg@N~YpH(l24w7%PuIr(JecgX(Y=Yl4Hu3qB9Id^76?HPSpK&g^aovze4_+Iq3ng1f045}G#=FpY$^I1r z8vmyX;J@IpmkyaE6(zzY=;L>r9%v+>yYh@|ro5#`&5cKjTem;3AUQ7hYK z8`-BNhLf`M`}Q0SEpsL{hJE5AMgu^Y>du{S&cMSRvJtY4jAwIz=o`EugY-7jt^(c9 zEln~yC(4^!mW7mFSDalH6|addl2`2}oAm3?KWCl2wrsuLt6P9E92FqmAqcR^#6_6t z(_xUms%LoNiy;?2$3+%O+|NC`VB%CRDky=SkX|yi$i;`+NO}5mNV+_D*G`cbDKYr< z^3m|di*WNoxIq*UZXWix?QPI~XdU>+FFAhKs&w#;rFBA`VYx+Srh=TvzpHeMgmTOmo^vWc{u#aGvTTd_B;6lp=Q3&<4l#D zoBypOMB!t6B{B7;zP}UvTbiFMg`73)KBX+OGTP3G441f{rIE_{aUWRRI|OZAQW!S{ z?W(3Nl26x-?dE&AW)XqGi+&!=aWUfzn|OOWj2*Esyl3NF6b*{ODmqFU-(@@=Y>4gG z4s_q&jMF95e2aP&rKvM1?>e%;-uR7m7!QE7ru0Z!;(wRUpouV+xcgbyUB00D@zp9R z?Hrpux>vVM=Mt3@$EVsHpeC4OOhZ$o`Z1tz{?g@7*XLhT;-q%sVO^W|rLUUDHozRf zE9*lJ`d*?_!P({?K)}f=XY<$pr=g05y-}pa%dnBQAc3FaUrW13{ohLJ%nMd{h)53JMmW{fi9Q z=W~K-2p&2XTZB@?0Ui*Dg9d;wKdHiyFlYIMT;F1rKmieM z6#Ml!j=yM^mP{gy`1;-ZMA$W1%PfaLgl`_FQ)m1Vst2rbdC^aEqcJcps&FBHCLL?s zafFEBWK;#6_W^F;ebRKMOsEOBZK{+-1i>suRsHiy$t4Em*}C^L{R4P{R1FN>5i20t zGMo?<={uFF7U!zTVUM4B-M0PeX9a#zaa2&aX{+m4y&~MhS0RK$Zoco|^%(n>t~KAg z#B@RbQqS#`={|?yTV0VBjFX=$daanY&?i<8sKfR(>&)0=-dyYB^7)jZ zEk;^0)T~~FCn3=5G>?Y?rPjs`^Sl+&7YdJwBw_!8A} z(LOVQOP0z|^f{h`70lg`UM_bX#?VVv8$H$8GF=c9f-&--bsTtWwFli_=8_aychv@LhMxO($?l~_;MxeN9d#a+pydjECM*QMipi>V_|C>u zmp3NHih9n$JHb_wJpiSz>I`Doih1Jp@k1`Vk5})ywsN!SQGsBPJe6S-dRRlj=d);SE~_KP6n6Ic7?ED*TP14dxZb$L+C1*a1402{ zS=)L!`M~U)Jdx+7&o=Qx>7QVoMS}G$609$Of|bw+ud!06g)Ca??(!lro20>C4iyp% z1w)9?v9Xewqf&M`?10zEP;KF^P-+O}ZVdfl&Qq1X61|PI)zHT|H%4U3qC8StV&XPFd+oKH!50@d!c%czF1DkbJ-+ z{L|#UF#q58_jg=Vt8U*u@WaRj{6mI87FJ%>(}!~)t{!`+9->@V&Y^1Q`a(*>|8!dn z8lPA=u15T(#b^EO+f$-f1Hr1dsFG)Eh<2WpaxylS_81KD5a#IG&G>dyhQAacXqMm} z>^gbUaNK>ohGB$|z8%&a^FN&~carHUugGM*;& zaaFp}(5#%dvJV)2&r(yP8n5Q7BL=IS&(~-*ymqlWc^lz#5G_9kQX|Y07yOtT%H5VC z(OD+Q;9!}BTJV!=v>}=hoD2FO0D+K6A_78iVSs_aa}XK?75TVAKB3r@GC9h+cG<ykAFCNtxcUQCHVVgh&1Qm{)lu zKKZ_(a32xphiYoAj+gc=eL_H041N|GFSVAv%|SDCD)8w8?M@s%n6umW-xxj- z)P2uQ@~*$aF|RRFGKx%giPbtc+kN+SMd+)!EJ+#N>bO-Z6+IQ>FEP#b(2-qBjIqVr zCeQDSy=+*ZQ=poBGN92QIREx;mWQEX(G<~oe~YfhRGM9~ucB-@R~;*5cj6W#b+9te zW{jC+`-xW1^!S~~dCfP7k>WI@wF%@RyX% z|9eX3H~Ei#>+j&$S#)?-g^RKHW+c?8ASc3yMZi)qnx{W>U(ok;qUWQ^4#{WQu3h3x zw)Ed)9`c|k6s+#@^%-pk+MUskTpx`oZ7kDM@YGQwq;ul~Wsos;J(t>AxWy7s7%jaX zkXJj?hHb#x=wY4GC}|MOlBHd(McqnB4O8A4d!@bNMgoI=Q!0)1FYRYB#&HxU*DHyU z*$NpQ7kPU3wI7fLGw+1Cx0tfOV3svc%=22~+(WuAlL6Ahv-~1%-VWcsb^50ks+Rco z#7Zz*SPj`o<}LeU<)zSso;)65y`EbmZ?<+n$Oo}QM2SgE$3LHU{uK7`?7g;Vo;994 zW93RQJ_S6es`77Be=-@Np+IiC|PZoRW%Q+iL@vcU1wxU zepVQ%n;4a21Ps145Lte`K4@>g`v7Y;??slW-_uOQYMI?sss}41jxhaE;0g(j21;Z% zQqnKa-# zQ91=_KZjXP8sckO67hrb)kg$U#uRH>;RrK#U8Y&;Y+=pgX7fkUIb2Jl-8LN*0XuJX zq|(D_xGdgBO%T+NU_PXM#su-9dyLmGydP7v{hsw9iOVJWG2!koHy1l=q!0j_-`hds z`V;#g5eNb#fXx0hzhwIOJskFHX_b~&v5$t7>2N5{r7Q%YgHiN#e;Jry6j|wCJb(el zQ-^!Ic_DQkoq-d~7fJ}h|H&2@fAGLBPb6df#tcxROYTQ92Bs!*t7>x6T9*VN2odDr zhYIjPp?nuP{=($_!~E}W=hu<_?hjX6Gkq%468&Wo+ z(L4FUNR-OBjNhC0lJ+H+&FE)1yD}IhDRPDiQN~vDW)?`U5RCZ^AEBfil?+z7zOk@B zC9)egoyX_O_U_yR26B%lX4n|Vk1wtz<_o6fJSP2QG$W44Y+A5Pf5REnjWU>|bdFZ< z`y%-!VanG1K<&miY+8UxlvwmDw1SIs$mBj6(7`oF{Z*S8v_QZ7olWO1EzAXn5T7ZlT zYDQ3K1|;;sU6TLHr{MNukN^4|Bd`E}#y{@G7Qw%i$d#fMiH1vIfoCAIp`D;)1f*Ez zi;DS38{Swgd=TtDng7lVJ6I7SZ8dpqB;F~jw7(F?`fL@#rNqnpO8TKRiNw^Narmy> zwmp9Ma=WQh5@}z~P`Qx7P0NCnT)(j%3w}C`&x>v$??R&m-=;EZEzJu11o4O4J&jav z$WvVyC9Sy&+^uA`B>u8o@%|j$h1fa)<-5Rjna-Kk!Ij6-K2{2RBg>;gK>*@jHc$V1 zMUw=Wwg~cvR81pZ^}_d#kFYmmbMH|6c(KhrAGfp)HgH=X`Ld&@)>?8_?DyjoqB0St z8#JR>%d|n=JkZ7&s9_%!0JdVn!6Fu(6jwTK=TGoi)!RLdDZCICKmg{ihQLo*!SN2+ zDL_SX$~hAH*q7pr4TT7ZEVe-i(E1pj9eh}#8I3(r?^#1G){;>Xce*o5_;ckt5{#v) z2qJ0k{Fs}H-#e+b@98g>!6WZSM4U)&Qt+mR+!rr!Zz=6GT)nzsoCc1}mvRc+O$je_i*iLbvl znSSHz7?_mdsX&(z0$zjw7`;lql*#~DtGg?7f!gsp8$D3PmF~GS`iKo)TI0bq*WMxV7 zR^z{=pXd6Y4otf4V8kiisk7N^Fk(Yp^w(VZmOW|0w9pj_yTeLj5W9oo%g@ehSDa-E zD+V5uOfa17`cH!`@6Yu$| zX8TQjvkv?7#l(@rG;Kly-D@E^va)8j{gencC-jI0(^le>$V8w-@10e^aF$7zdCj?e z23KXIKE<~>D|vuADOIvH@Ae*0;U&VphvM|bXrH@g(dMMjbLKWa}n{~wfuHbZ%u9yoV7PW7!)3nA>QlX_a3u} zVAt$fah`07OtVy077MPN%T_g+jWsFGaW+M3WajHju_p%HFlI|AkRZhsll2*_z{5>j zR=3U|+n&3jB|YE$hVOkyGxM+_{t$3OZjVo(x+iL~CfwPg%;=%fn%%4~o7DkEKmA(+ z>nB{iKU`^ec`cKdcCoojIL4D_OG!iX_dWeryA<%cd8ZExCW53aV}=OlDjkbXVRZAT zv0ggmeFg)$ZF3V%ChR7BCxmG#FLGI&tAILS$q5Bb(MW%$5 zo_>rm^1QStbN5Eq^}Y_)SNOO*&eJVFF!*{dbZvKvI{Il=Ms$#?M?iK@*UB!M@_C+r z{EYpugFKF9!xTMg_IEUDG$ZE2y3xT%p7LFiM_z;K&4iG*b!jp#_T}#b;);mIYHq3r z%KOX2u>|)IXf#%_Vle-(nY+Q{yjbK-)g9P#BEJOh$ESbxLPN|%oT#6uQ!EZMmBS$h z9ERFyUp#?$K-)uGZSEJ6?Osu%>~1Mn*~W5h*MvEsBguN!aBgxNCx{`Ma`(KjdpUqHYZv}N6 z*GW^4=F7?&+Au1+P#HB3@C=@`hZxyEW@ADd;uo2Rl8YQ`8B3I=LU*eXTa zef@y=PQXSuZbh;YxF4x#pt8hF`ttc}%R^35;LFghxy=m@&iCUvkSv`RhwG`|9#Sshprx}F#z*nK& zL8Gy8HhcUgk0Q3At*qem2Q#pR?se8C|DlHt>yIJdc9K8kK(BMSAtJX zYoiCwvKvZHY&_l(GlaZ)b$`MWI7uEt+lX6_1)7i3ZVGZdjgc&p+5NcqrGh@3n*498 zD_LBly2O}6vAL5~>gc-$fu1XEeg7NPRe$d_uM>fJS2y#BWQNL2_6V>w<9ZR7L-3SR znvD}!R?l-aY-Aj(V@g)AO51@atl6rNVcJsf=0}SXtMHjc_6}8p!fTvt zka1XWe*2axV>2(D*#RwU*;IQv+|%g1DloCHgI7F@H1kU}j8c@aB=})srtu@OFDXZf z8lNR>d&4tK*yO^7XsR6HD=$hHV8xojJX5Ug2jh~o!-8Mch@;7k;qCH26z#mhWD!Aky;xlz+0tT1%C=XHAA7pI;OaYD)*CM-ic-U?$l({kRiWAR~}O zgmQw2P}Yl>2}J}I{<8v;h@iBKD1{CPxEQhjY=9^P82axIEI=@d4Fth?eb^ZL!y%oH z4gw$$LDq`jJk_1T5QaMGtd=(u2#y|^LmKzTTT`4}!ar^_diUL%7tc?oK0&4`B>VFF zJ|XvHFe~Ep4=1CkRh2t>)Gx0;O~-SD;HU3ch-k`P>93>)TS|O7sc{yZ+)vnGP%yB$ zdgEz*Erd;I`Qc&-7+X%a@c&6r<45b+nhcid1hqnc{5Lh+&GI79dwo zI;WqWkQ2_GiWV5ju(3|>xj2_ltu0%RZ86P~h+UMKoVvR2$SHUCo0i}>GXlotNfg0k zrCOvuc9A(6 z&N1xskA;ys-x{6hM1y7(&{EXP4CQt_&y6z9a~kqesUE7u$R&F}27FMsx!dg$LJLw2 zko=YHmn{~tW!&3FsHfg*J#APlr8R0Bh53_6+EVyFK9MJs>@Oro`q$TetSoh7D2uu+ zqS+IN(>Lx=xxN~@)6?e7@D@?|Ef9-3lz+phPs1NSHrhm4k?QhbOnQ4JQ#1QV@j4;( zwR<`hwkC`1`>G#`EI^FEy{PS%q%m&HgoXX`^o1PEeKc^#p(*Jn<48$Eg=1VEBkV+@B$M zUVQsYo2^MIx}M?!ed-=IS(GHPeMRE&uF;|PjHe%MWbh@&*}bb~(nC9(dOyB#TWvm* ze$>@erzGsAjKH9LBmKv!y9nnX!BJ|Uw3|am7gg+taAO2()Hkc=w5b)9{)|(fmHA6Q z4}P_hMk{{TdacXTrlnPqEiyr#;!ZmCFP3YrO^1!cEHwFtg&Rs0+X~K#ZzB%Gc58X2&-r$zR9i|)S&;x;2RVHb}@l*;V zzIj*P8zask)7nXZyB=58T9nX>s`PhEAhN=42gg?{v0h3Ej{a_j7J-jN@11#GvwEiE zMrT*c;$xBfr{BG?t#wD;K!zK&Id*fYcb}Sw8vIo62CTQ+oH%kl3|TEsZyzmQBZdWD zD|IYf<_OJACtWe$R%od7&OA<0m1*{JLJ=99{s$rwk--8)WH7mi4KGR$%={mgpg_6{ zzxFQR+WtSS=>OL06?~eK2`*m!TPqL|)K_TLiH(+JYGojaKd>|Ya6~n{-nHp05f+`O zz?4J;8jJvKK58ev`M%`eUSKz=Jr1#C4*G%Zc+$m}*feG%V-w>gG+)2JO`$(iN@AYN zTVt+v!K!LiN(W00=z1jFl9&$QwT2qUI&M6}gyE(%IGI~d`ci+s6{`wnRr9_X#JE*F z5xRM-B|M<+>5}aJF26;uO3EHK*{UAU0G@@V?iOMdDG2YM9KC~%07Y+I@tv02{5V0^ z{?Uouxr%{`mI-ZEX@XSq0PBpr$<~{r0oQ#lu8j=oPR9f+0f`Ivu4Ed9jPU@bM<4B6ghJce4qy?mSXPry60#5|ZMZ))&rv;4p@)XbAb4 zQKEFm#d>}JmV6Vpp0z<4q;%c^ z-@5Wk_Uq8CS@Rm_C9gECfH8sY5E0(TahVz;dI8eBqL@fU2gR&`NK}i@HI0Qwy7pTL zwPfhQBH`h_XE^2jbI8KNUJsxd&=>t{w~iB+`k!t2xjk?0^vdVwOFM)H?~Ydc6c?DQbco@TwH-ZOv+dVP@;9Q%$T_%>)(5h3w4*@`j=MT?I9c5>mClbetQEHav7t^J^YTAM7k#&kB|+ zblnt}*ZdUKXuy}it+KSqZK7cri7=p+M=~zKQgpvcb-qZ?ex_lv4qO(r4~e!zlwh}@ZhQh`h^d42!i#%$nEE9zAV;jC$dUNTpxF2H$2#S zmYj4jcC=ued>^!XEoZ^s6kDdvNbpq6@0$kbsOBhj8YS`i*UJ6@#H)<3`!vk4&zzMq zFDbJ$n%Y(d;l3RyigC6Gw`MmEm%{_vdIR1OB{{81Z)Wz2x86RB(3atqraxSXxv>t< z`ELLDc~VKek_@Ry?DX!fTPtmvm%VlG?xc9u-3Mn^Rv8Hxb9{p8d|hh=vL(aH5-RFr zvMh#FNNC7X?}}FclB;sqS}B?^;-de=ez}5+Xf>cE>awFp$07E3p}&%=+pHAt!OEeD z(Qo`|PhV+8<3`v;T?*%Z?q!BQrtxL>DPSqp%b&4j2aS%R5WUw);&pru*;6@ZF*6Hj zU6jawb!6f}a|v?*f&i|7z>Dq+@B_F2Tv5n>4q#|Fh(}-ws&R0@(dfSdY)s7Mr?+E+ z#iP(DF%%P+L5_`{PJjUb;%PkiJv;_~SIQ&Cv_`mEBE2JL&H)5D>1{%}NTz)Lo6)}j D&}!D= literal 0 HcmV?d00001 diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem new file mode 100644 index 00000000000..5a67e103344 --- /dev/null +++ b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,9D867F7E0C94D013 + +dVoVCjPeg1wgS7rVtOvGfQcrZyLkx393aWRnFq45tbjKBVuITtJ9vI7o4QXOV/15 +Gnb6WhXGIdWrzsxEAd46K6hIuNSISd4Emsx6c2Q5hTqWXXfexbOZBNfTtXtdJPnJ +1jAaikhtztLo3JSLTKNY5sNxd+XbaQyYVUWvueK6zOaIIMETvB+VPVFd9i1ROibk +Sgdtyj01KjkoalifqK/tA0CIYNKL0S6/eoK3UhAlpIprlpV+cnXa940C6bjLeJPt +PMAGGp5RrplxSgrSerw3I9DOWkHGtpqzIka3XneNUXJP8k4HUJ+aZkGH2ZILKS8d +4KMIb+KZSpHEGn+6uGccWLtZZmAjWJrDw56JbQtSHdRYLBRSOjLbTvQoPu/2Hpli +7HOxbotlvjptMunncq5aqK57SHA1dh0cwF7J3LUmGFJ67eoz+VV3b5qMn4MopSeI +mS16Ydd3nGpjSrln/elM0CQxqWfcOAXRZpDpFUQoXcBrLVzvz2DBl/0CrTRLhgzi +CO+5/IVcBWRlYpRNGgjjP7q0j6URID3jk5J06fYQXmBiwQT5j+GZqqzpMCJ9mIy2 +1O9SN1hebJnIcEU+E0njn/MGjlYdPywhaCy8pqElp6Q8TUEJpwLRFO/owCoBet/n +ZmCXUjfCGhc1pWHufFcDEQ6xMgEWWY/tdwCZeSU7EhErTjCbfupg+55A5fpDml0m +3wH4CFcuRjlqyx6Ywixm1ATeitDtJl5HQTw6b8OtEXwSgRmZ0eSqSRVk9QbVS7gu +IpQe09/Zimb5HzjZqZ3fdqHlcW4xax8hyJeyIvF5ZJ57eY8CBvu/wP2GDn26QnvF +xQqdfDbq1H4JmpwUHpbFwBoQK4Q6WFd1z4EA9bRQeo3H9PoqoOwMDjzajwLRF7b7 +q6tYH/n9PyHwdf1c4fFwgSmL1toXGfKlA9hjIaLsRSDD6srT5EdUk78bsnddwI51 +tu7C7P4JG+h1VdRNMNTlqtileWsIE7Nn2A1OkcUxZdF5mamENpDpJcHePLto6c8q +FKiwyFMsxhgsj6HK2HqO+UA4sX5Ni4oHwiPmb//EZLn045M5i1AN26KosJmb8++D +sgR5reWRy+UqJCTYblVg+7Dx++ggUnfxVyQEsWmw5r5f4KU5wXBkvoVMGtPNa9DE +n/uLtObD1qkNL38pRsr2OGRchYCgEoKGqEISBP4knfGXLOlWiW/246j9QzI97r1u +tvy7fKg28G7AUz9l6bpewsPHefBUeRQeieP9eJINaEpxkF/w2RpKDLpQjWxwDDOM +s+D0mrBMJve17AmJ8rMw6dIQPZYNZ88/jz1uQuUwQ2YlbmtZbCG81k9YMFGEU9XS +cyhJxj8hvYnt2PR5Z9/cJPyWOs0m/ufOeeQQ8SnU/lzmrQnpzUd2Z6p5i/B7LdRP +n1kX+l1qynuPnjvBz4nJQE0p6nzW8RyCDSniC9mtYtZmhgC8icqxgbvS7uEOBIYJ +NbK+0bEETTO34iY/JVTIqLOw3iQZYMeUpxpj6Phgx/oooxMTquMecPKNgeVtaBst +qjTNPX0ti1/HYpZqzYi8SV8YjHSJWCVMsZjKPr3W/HIcCKqYoIfgzi83Ha2KMQx6 +-----END RSA PRIVATE KEY----- diff --git a/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks b/plugin/security/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks new file mode 100644 index 0000000000000000000000000000000000000000..f18b9288b10b82dd290fe5586130a90a045239ef GIT binary patch literal 1048 zcmezO_TO6u1_mY|W(3n5C8@ zGZP~d6DPxtojK-@jn14l;AP{~YV&CO&dbQi&B|clVaQ{^#l{@U!X?a{UzBbrW*`FM zaSQXN<|G!EWF{Au;%Ds)kjQ&@WJ-SlfJZ}2NuO)CfLF8@q*LL?X zuLo+P`?p+(|Dh|&xWDoJop*0_bWhYS-+sIN{qZ!VOaC^wq!?+m{Seu2{haxHpJL~S zN8TH?`hRxrVo=mGofNF_FF<(q(dsLkC0?Ic-gfWn-s9VvDRe6Eh3K?TOyrrD1VUG(tnTJ%;??Q@+#z+dfZ-UIM>K*ce}tnhb6MP zZoz@~-pad-^VQN>XFrS%ywOq=@qc~wgyRQ|ZD)(ldbJ@{+FD>m-HZvdA{W`bn*4Ku z-wV6sV=XhIv|O6c$gR)Ff3kPwz0~FYbw<}T4}8CDFMrnjjgL^5cx3(o*I#a}$xoU; z=5f6H_CFC5q>+EkiyEHl!i?1_8!|Lup3 zQsy|F?yxE}=DDkX#pquB&qa(kCg>TgS;zmNO?bh)z4r>4-t2SEJaFY^N5Z!?=K$I+ Bn+gB` literal 0 HcmV?d00001 diff --git a/plugin/sql/build.gradle b/plugin/sql/build.gradle index 3446f937b04..6b8940d6960 100644 --- a/plugin/sql/build.gradle +++ b/plugin/sql/build.gradle @@ -15,13 +15,13 @@ dependencyLicenses { dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" // sql's server components and its transitive dependencies // TODO: what to do about this dependency, is it still needed? // compile project(':x-pack-elasticsearch:sql:server') } -parent.bundlePlugin { - from jar -} +//project(':x-pack-elasticsearch:plugin:core').bundlePlugin { +// from jar +//} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/plugin/src/main/java/org/elasticsearch/xpack/XPackPlugin.java deleted file mode 100644 index 132e2267b6a..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ /dev/null @@ -1,517 +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; - -import org.bouncycastle.operator.OperatorCreationException; -import org.elasticsearch.SpecialPermission; -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.client.transport.TransportClient; -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.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.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.AnalysisProvider; -import org.elasticsearch.indices.breaker.CircuitBreakerService; -import org.elasticsearch.ingest.Processor; -import org.elasticsearch.license.LicenseService; -import org.elasticsearch.license.Licensing; -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.action.TransportXPackInfoAction; -import org.elasticsearch.xpack.action.TransportXPackUsageAction; -import org.elasticsearch.xpack.action.XPackInfoAction; -import org.elasticsearch.xpack.action.XPackUsageAction; -import org.elasticsearch.xpack.deprecation.Deprecation; -import org.elasticsearch.xpack.extensions.XPackExtension; -import org.elasticsearch.xpack.extensions.XPackExtensionsService; -import org.elasticsearch.xpack.graph.Graph; -import org.elasticsearch.xpack.logstash.Logstash; -import org.elasticsearch.xpack.logstash.LogstashFeatureSet; -import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.monitoring.Monitoring; -import org.elasticsearch.xpack.persistent.CompletionPersistentTaskAction; -import org.elasticsearch.xpack.persistent.PersistentTasksClusterService; -import org.elasticsearch.xpack.persistent.PersistentTasksExecutor; -import org.elasticsearch.xpack.persistent.PersistentTasksExecutorRegistry; -import org.elasticsearch.xpack.persistent.PersistentTasksService; -import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction; -import org.elasticsearch.xpack.persistent.StartPersistentTaskAction; -import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction; -import org.elasticsearch.xpack.rest.action.RestXPackInfoAction; -import org.elasticsearch.xpack.rest.action.RestXPackUsageAction; -import org.elasticsearch.xpack.security.Security; -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 org.elasticsearch.xpack.upgrade.Upgrade; -import org.elasticsearch.xpack.watcher.Watcher; - -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.Map; -import java.util.Set; -import java.util.TreeMap; -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; -import java.util.stream.Stream; - -public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, IngestPlugin, NetworkPlugin, ClusterPlugin, - DiscoveryPlugin, MapperPlugin, AnalysisPlugin { - - // 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 XPackExtensionsService extensionsService; - - protected XPackLicenseState licenseState; - protected SSLService sslService; - protected Licensing licensing; - protected Security security; - protected Monitoring monitoring; - protected Watcher watcher; - protected Graph graph; - protected MachineLearning machineLearning; - protected Logstash logstash; - - protected Deprecation deprecation; - protected Upgrade upgrade; - - public XPackPlugin( - final Settings settings, - final Path configPath) throws IOException, DestroyFailedException, OperatorCreationException, GeneralSecurityException { - this.settings = settings; - this.transportClientMode = transportClientMode(settings); - this.env = transportClientMode ? null : new Environment(settings, configPath); - this.licenseState = new XPackLicenseState(); - this.sslService = new SSLService(settings, env); - - this.licensing = new Licensing(settings); - this.security = new Security(settings, env, licenseState, sslService); - this.monitoring = new Monitoring(settings, licenseState); - this.watcher = new Watcher(settings); - this.graph = new Graph(settings); - this.machineLearning = new MachineLearning(settings, env, licenseState); - this.logstash = new Logstash(settings); - this.deprecation = new Deprecation(); - this.upgrade = new Upgrade(settings); - // Check if the node is a transport client. - if (transportClientMode == false) { - this.extensionsService = new XPackExtensionsService(settings, resolveXPackExtensionsFile(env), getExtensions()); - } else { - this.extensionsService = null; - } - } - - // For tests only - public Collection> getExtensions() { - return Collections.emptyList(); - } - - // overridable by tests - protected Clock getClock() { - return Clock.systemUTC(); - } - - @Override - public Collection createGuiceModules() { - ArrayList modules = new ArrayList<>(); - modules.add(b -> b.bind(Clock.class).toInstance(getClock())); - modules.addAll(security.nodeModules()); - modules.addAll(monitoring.nodeModules()); - modules.addAll(watcher.nodeModules()); - modules.addAll(graph.createGuiceModules()); - modules.addAll(machineLearning.nodeModules()); - modules.addAll(logstash.nodeModules()); - - if (transportClientMode) { - modules.add(b -> b.bind(XPackLicenseState.class).toProvider(Providers.of(null))); - } - 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.add(sslService); - - LicenseService licenseService = new LicenseService(settings, clusterService, getClock(), - env, resourceWatcherService, licenseState); - components.add(licenseService); - components.add(licenseState); - - try { - components.addAll(security.createComponents(client, threadPool, clusterService, resourceWatcherService, - extensionsService.getExtensions())); - } catch (final Exception e) { - throw new IllegalStateException("security initialization failed", e); - } - components.addAll(monitoring.createComponents(client, threadPool, clusterService, licenseService, sslService)); - - components.addAll(watcher.createComponents(getClock(), scriptService, client, licenseState, threadPool, clusterService, - xContentRegistry, sslService)); - - PersistentTasksService persistentTasksService = new PersistentTasksService(settings, clusterService, threadPool, client); - - components.addAll(machineLearning.createComponents(client, clusterService, threadPool, xContentRegistry, - persistentTasksService)); - List> tasksExecutors = new ArrayList<>(); - tasksExecutors.addAll(machineLearning.createPersistentTasksExecutors(clusterService)); - - components.addAll(upgrade.createComponents(client, clusterService, threadPool, resourceWatcherService, - scriptService, xContentRegistry)); - - PersistentTasksExecutorRegistry registry = new PersistentTasksExecutorRegistry(settings, tasksExecutors); - PersistentTasksClusterService persistentTasksClusterService = new PersistentTasksClusterService(settings, registry, clusterService); - components.add(persistentTasksClusterService); - components.add(persistentTasksService); - components.add(registry); - - // just create the reloader as it will pull all of the loaded ssl configurations and start watching them - new SSLConfigurationReloader(settings, env, sslService, resourceWatcherService); - return components; - } - - @Override - public Settings additionalSettings() { - Settings.Builder builder = Settings.builder(); - builder.put(security.additionalSettings()); - builder.put(watcher.additionalSettings()); - builder.put(machineLearning.additionalSettings()); - return builder.build(); - } - - @Override - public Collection getRestHeaders() { - if (transportClientMode) { - return Collections.emptyList(); - } - Set headers = new HashSet<>(); - headers.add(UsernamePasswordToken.BASIC_AUTH_HEADER); - if (AuthenticationServiceField.RUN_AS_ENABLED.get(settings)) { - headers.add(AuthenticationServiceField.RUN_AS_USER_HEADER); - } - headers.addAll(extensionsService.getExtensions().stream() - .flatMap(e -> e.getRestHeaders().stream()).collect(Collectors.toList())); - return headers; - } - - @Override - public List getContexts() { - return watcher.getContexts(); - } - - @Override - public List> getSettings() { - ArrayList> settings = new ArrayList<>(); - settings.addAll(Security.getSettings(transportClientMode, extensionsService)); - settings.addAll(monitoring.getSettings()); - settings.addAll(watcher.getSettings()); - settings.addAll(machineLearning.getSettings()); - settings.addAll(licensing.getSettings()); - 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 List getSettingsFilter() { - List filters = new ArrayList<>(); - filters.addAll(watcher.getSettingsFilter()); - filters.addAll(security.getSettingsFilter(extensionsService)); - filters.addAll(monitoring.getSettingsFilter()); - if (transportClientMode == false) { - for (XPackExtension extension : extensionsService.getExtensions()) { - filters.addAll(extension.getSettingsFilter()); - } - } - return filters; - } - - @Override - public List> getExecutorBuilders(final Settings settings) { - List> executorBuilders = new ArrayList>(); - executorBuilders.addAll(watcher.getExecutorBuilders(settings)); - executorBuilders.addAll(machineLearning.getExecutorBuilders(settings)); - executorBuilders.addAll(security.getExecutorBuilders(settings)); - return executorBuilders; - } - - @Override - public List> getActions() { - List> actions = new ArrayList<>(); - actions.add(new ActionHandler<>(XPackInfoAction.INSTANCE, TransportXPackInfoAction.class)); - actions.add(new ActionHandler<>(XPackUsageAction.INSTANCE, TransportXPackUsageAction.class)); - actions.add(new ActionHandler<>(StartPersistentTaskAction.INSTANCE, StartPersistentTaskAction.TransportAction.class)); - actions.add(new ActionHandler<>(UpdatePersistentTaskStatusAction.INSTANCE, UpdatePersistentTaskStatusAction.TransportAction.class)); - actions.add(new ActionHandler<>(RemovePersistentTaskAction.INSTANCE, RemovePersistentTaskAction.TransportAction.class)); - actions.add(new ActionHandler<>(CompletionPersistentTaskAction.INSTANCE, CompletionPersistentTaskAction.TransportAction.class)); - actions.addAll(licensing.getActions()); - actions.addAll(monitoring.getActions()); - actions.addAll(security.getActions()); - actions.addAll(watcher.getActions()); - actions.addAll(graph.getActions()); - actions.addAll(machineLearning.getActions()); - actions.addAll(deprecation.getActions()); - actions.addAll(upgrade.getActions()); - return actions; - } - - @Override - public List getActionFilters() { - List filters = new ArrayList<>(); - filters.addAll(licensing.getActionFilters()); - filters.addAll(monitoring.getActionFilters()); - filters.addAll(security.getActionFilters()); - filters.addAll(watcher.getActionFilters()); - filters.addAll(machineLearning.getActionFilters()); - filters.addAll(upgrade.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.add(new RestXPackInfoAction(settings, restController)); - handlers.add(new RestXPackUsageAction(settings, restController)); - handlers.addAll(licensing.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(monitoring.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(security.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(watcher.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(graph.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(machineLearning.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(deprecation.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - handlers.addAll(upgrade.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, - indexNameExpressionResolver, nodesInCluster)); - return handlers; - } - - @Override - public Map getProcessors(Processor.Parameters parameters) { - return security.getProcessors(parameters); - } - - @Override - public List getNamedWriteables() { - List entries = new ArrayList<>(); - entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XpackField.LOGSTASH, LogstashFeatureSet.Usage::new)); - entries.addAll(watcher.getNamedWriteables()); - entries.addAll(machineLearning.getNamedWriteables()); - entries.addAll(licensing.getNamedWriteables()); - entries.addAll(Security.getNamedWriteables()); - entries.addAll(Monitoring.getNamedWriteables()); - entries.addAll(Graph.getNamedWriteables()); - return entries; - } - - @Override - public List getNamedXContent() { - List entries = new ArrayList<>(); - entries.addAll(watcher.getNamedXContent()); - entries.addAll(machineLearning.getNamedXContent()); - entries.addAll(licensing.getNamedXContent()); - return entries; - } - - @Override - public UnaryOperator> getIndexTemplateMetaDataUpgrader() { - return templates -> { - templates = watcher.getIndexTemplateMetaDataUpgrader().apply(templates); - templates = security.getIndexTemplateMetaDataUpgrader().apply(templates); - templates = logstash.getIndexTemplateMetaDataUpgrader().apply(templates); - templates = machineLearning.getIndexTemplateMetaDataUpgrader().apply(templates); - return templates; - }; - } - - @Override - public Map> getTokenizers() { - Map> tokenizers = new TreeMap<>(); - tokenizers.putAll(machineLearning.getTokenizers()); - return tokenizers; - } - - public void onIndexModule(IndexModule module) { - security.onIndexModule(module); - watcher.onIndexModule(module); - } - - public static void bindFeatureSet(Binder binder, Class featureSet) { - binder.bind(featureSet).asEagerSingleton(); - Multibinder featureSetBinder = Multibinder.newSetBinder(binder, XPackFeatureSet.class); - featureSetBinder.addBinding().to(featureSet); - } - - public static boolean transportClientMode(Settings settings) { - return TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())); - } - - public static Path resolveConfigFile(Environment env, String name) { - return env.configFile().resolve(XpackField.NAME).resolve(name); - } - - public static Path resolveXPackExtensionsFile(Environment env) { - return env.pluginsFile().resolve(XpackField.NAME).resolve("extensions"); - } - - @Override - public List getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry, ThreadContext threadContext) { - return security.getTransportInterceptors(namedWriteableRegistry, threadContext); - } - - @Override - public Map> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, - PageCacheRecycler pageCacheRecycler, - CircuitBreakerService circuitBreakerService, - NamedWriteableRegistry namedWriteableRegistry, - NetworkService networkService) { - return security.getTransports(settings, threadPool, bigArrays, pageCacheRecycler, circuitBreakerService, namedWriteableRegistry, - networkService); - } - - @Override - public Map> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, - CircuitBreakerService circuitBreakerService, - NamedWriteableRegistry namedWriteableRegistry, - NamedXContentRegistry xContentRegistry, - NetworkService networkService, - HttpServerTransport.Dispatcher dispatcher) { - return security.getHttpTransports(settings, threadPool, bigArrays, circuitBreakerService, namedWriteableRegistry, xContentRegistry, - networkService, dispatcher); - } - - @Override - public UnaryOperator getRestHandlerWrapper(ThreadContext threadContext) { - return security.getRestHandlerWrapper(threadContext); - } - - @Override - public List getBootstrapChecks() { - return Collections.unmodifiableList( - Stream.of(security.getBootstrapChecks(), watcher.getBootstrapChecks(env)) - .flatMap(Collection::stream) - .collect(Collectors.toList())); - } - - @Override - public Map> getInitialClusterStateCustomSupplier() { - return security.getInitialClusterStateCustomSupplier(); - } - - @Override - public BiConsumer getJoinValidator() { - return security.getJoinValidator(); - } - - @Override - public Function> getFieldFilter() { - return security.getFieldFilter(); - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashSecurityExtension.java b/plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashSecurityExtension.java deleted file mode 100644 index 4a418eb6667..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/logstash/LogstashSecurityExtension.java +++ /dev/null @@ -1,34 +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.logstash; - -import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.SecurityExtension; -import org.elasticsearch.xpack.security.support.MetadataUtils; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class LogstashSecurityExtension implements SecurityExtension { - @Override - public Map getReservedRoles() { - Map roles = new HashMap<>(); - - roles.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)); - - return Collections.unmodifiableMap(roles); - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java deleted file mode 100644 index 8074405129b..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java +++ /dev/null @@ -1,319 +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.ml; - -import org.apache.lucene.util.Constants; -import org.apache.lucene.util.Counter; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.env.Environment; -import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.plugins.Platforms; -import org.elasticsearch.xpack.XPackClientActionPlugin; -import org.elasticsearch.xpack.XPackFeatureSet; -import org.elasticsearch.xpack.XPackPlugin; -import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; -import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction; -import org.elasticsearch.xpack.ml.action.GetJobsStatsAction; -import org.elasticsearch.xpack.ml.datafeed.DatafeedState; -import org.elasticsearch.xpack.ml.job.config.Job; -import org.elasticsearch.xpack.ml.job.config.JobState; -import org.elasticsearch.xpack.ml.job.process.NativeController; -import org.elasticsearch.xpack.ml.job.process.NativeControllerHolder; -import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSizeStats; -import org.elasticsearch.xpack.ml.utils.StatsAccumulator; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeoutException; - -import static org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction.Response.DatafeedStats; -import static org.elasticsearch.xpack.ml.action.GetJobsStatsAction.Response.JobStats; - -public class MachineLearningFeatureSet implements XPackFeatureSet { - - /** - * List of platforms for which the native processes are available - */ - private static final List mlPlatforms = - Arrays.asList("darwin-x86_64", "linux-x86_64", "windows-x86_64"); - - private final boolean enabled; - private final XPackLicenseState licenseState; - private final ClusterService clusterService; - private final Client client; - private final Map nativeCodeInfo; - - @Inject - public MachineLearningFeatureSet(Environment environment, ClusterService clusterService, Client client, - @Nullable XPackLicenseState licenseState) { - this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(environment.settings()); - this.clusterService = Objects.requireNonNull(clusterService); - this.client = Objects.requireNonNull(client); - this.licenseState = licenseState; - Map nativeCodeInfo = NativeController.UNKNOWN_NATIVE_CODE_INFO; - // Don't try to get the native code version if ML is disabled - it causes too much controversy - // if ML has been disabled because of some OS incompatibility. Also don't try to get the native - // code version in the transport or tribe client - the controller process won't be running. - if (enabled && XPackPlugin.transportClientMode(environment.settings()) == false - && XPackClientActionPlugin.isTribeClientNode(environment.settings()) == false) { - try { - if (isRunningOnMlPlatform(true)) { - NativeController nativeController = NativeControllerHolder.getNativeController(environment); - if (nativeController != null) { - nativeCodeInfo = nativeController.getNativeCodeInfo(); - } - } - } catch (IOException | TimeoutException e) { - Loggers.getLogger(MachineLearningFeatureSet.class).error("Cannot get native code info for Machine Learning", e); - throw new ElasticsearchException("Cannot communicate with Machine Learning native code"); - } - } - this.nativeCodeInfo = nativeCodeInfo; - } - - static boolean isRunningOnMlPlatform(boolean fatalIfNot) { - return isRunningOnMlPlatform(Constants.OS_NAME, Constants.OS_ARCH, fatalIfNot); - } - - static boolean isRunningOnMlPlatform(String osName, String osArch, boolean fatalIfNot) { - String platformName = Platforms.platformName(osName, osArch); - if (mlPlatforms.contains(platformName)) { - return true; - } - if (fatalIfNot) { - throw new ElasticsearchException("X-Pack is not supported and Machine Learning is not available for [" + platformName - + "]; you can use the other X-Pack features (unsupported) by setting xpack.ml.enabled: false in elasticsearch.yml"); - } - return false; - } - - @Override - public String name() { - return XpackField.MACHINE_LEARNING; - } - - @Override - public String description() { - return "Machine Learning for the Elastic Stack"; - } - - @Override - public boolean available() { - return licenseState != null && licenseState.isMachineLearningAllowed(); - } - - @Override - public boolean enabled() { - return enabled; - } - - @Override - public Map nativeCodeInfo() { - return nativeCodeInfo; - } - - @Override - public void usage(ActionListener listener) { - ClusterState state = clusterService.state(); - MlMetadata mlMetadata = state.getMetaData().custom(MLMetadataField.TYPE); - - // Handle case when usage is called but MlMetadata has not been installed yet - if (mlMetadata == null) { - listener.onResponse(new Usage(available(), enabled, - Collections.emptyMap(), Collections.emptyMap())); - } else { - new Usage.Retriever(client, mlMetadata, available(), enabled()).execute(listener); - } - } - - public static class Usage extends XPackFeatureSet.Usage { - - private static final String ALL = "_all"; - private static final String JOBS_FIELD = "jobs"; - private static final String DATAFEEDS_FIELD = "datafeeds"; - private static final String COUNT = "count"; - private static final String DETECTORS = "detectors"; - private static final String MODEL_SIZE = "model_size"; - - private final Map jobsUsage; - private final Map datafeedsUsage; - - public Usage(boolean available, boolean enabled, Map jobsUsage, - Map datafeedsUsage) { - super(XpackField.MACHINE_LEARNING, available, enabled); - this.jobsUsage = Objects.requireNonNull(jobsUsage); - this.datafeedsUsage = Objects.requireNonNull(datafeedsUsage); - } - - public Usage(StreamInput in) throws IOException { - super(in); - this.jobsUsage = in.readMap(); - this.datafeedsUsage = in.readMap(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeMap(jobsUsage); - out.writeMap(datafeedsUsage); - } - - @Override - protected void innerXContent(XContentBuilder builder, Params params) throws IOException { - super.innerXContent(builder, params); - if (jobsUsage != null) { - builder.field(JOBS_FIELD, jobsUsage); - } - if (datafeedsUsage != null) { - builder.field(DATAFEEDS_FIELD, datafeedsUsage); - } - } - - public static class Retriever { - - private final Client client; - private final MlMetadata mlMetadata; - private final boolean available; - private final boolean enabled; - private Map jobsUsage; - private Map datafeedsUsage; - - public Retriever(Client client, MlMetadata mlMetadata, boolean available, boolean enabled) { - this.client = Objects.requireNonNull(client); - this.mlMetadata = mlMetadata; - this.available = available; - this.enabled = enabled; - this.jobsUsage = new LinkedHashMap<>(); - this.datafeedsUsage = new LinkedHashMap<>(); - } - - public void execute(ActionListener listener) { - if (enabled == false) { - listener.onResponse(new Usage(available, enabled, Collections.emptyMap(), Collections.emptyMap())); - return; - } - - // Step 2. Extract usage from datafeeds stats and return usage response - ActionListener datafeedStatsListener = - ActionListener.wrap(response -> { - addDatafeedsUsage(response); - listener.onResponse(new Usage( - available, enabled, jobsUsage, datafeedsUsage)); - }, - error -> { - listener.onFailure(error); - } - ); - - // Step 1. Extract usage from jobs stats and then request stats for all datafeeds - GetJobsStatsAction.Request jobStatsRequest = new GetJobsStatsAction.Request(MetaData.ALL); - ActionListener jobStatsListener = ActionListener.wrap( - response -> { - addJobsUsage(response); - GetDatafeedsStatsAction.Request datafeedStatsRequest = - new GetDatafeedsStatsAction.Request(GetDatafeedsStatsAction.ALL); - client.execute(GetDatafeedsStatsAction.INSTANCE, datafeedStatsRequest, - datafeedStatsListener); - }, - error -> { - listener.onFailure(error); - } - ); - - // Step 0. Kick off the chain of callbacks by requesting jobs stats - client.execute(GetJobsStatsAction.INSTANCE, jobStatsRequest, jobStatsListener); - } - - private void addJobsUsage(GetJobsStatsAction.Response response) { - StatsAccumulator allJobsDetectorsStats = new StatsAccumulator(); - StatsAccumulator allJobsModelSizeStats = new StatsAccumulator(); - - Map jobCountByState = new HashMap<>(); - Map detectorStatsByState = new HashMap<>(); - Map modelSizeStatsByState = new HashMap<>(); - - Map jobs = mlMetadata.getJobs(); - List jobsStats = response.getResponse().results(); - for (JobStats jobStats : jobsStats) { - ModelSizeStats modelSizeStats = jobStats.getModelSizeStats(); - int detectorsCount = jobs.get(jobStats.getJobId()).getAnalysisConfig() - .getDetectors().size(); - double modelSize = modelSizeStats == null ? 0.0 - : jobStats.getModelSizeStats().getModelBytes(); - - allJobsDetectorsStats.add(detectorsCount); - allJobsModelSizeStats.add(modelSize); - - JobState jobState = jobStats.getState(); - jobCountByState.computeIfAbsent(jobState, js -> Counter.newCounter()).addAndGet(1); - detectorStatsByState.computeIfAbsent(jobState, - js -> new StatsAccumulator()).add(detectorsCount); - modelSizeStatsByState.computeIfAbsent(jobState, - js -> new StatsAccumulator()).add(modelSize); - } - - jobsUsage.put(ALL, createJobUsageEntry(jobs.size(), allJobsDetectorsStats, - allJobsModelSizeStats)); - for (JobState jobState : jobCountByState.keySet()) { - jobsUsage.put(jobState.name().toLowerCase(Locale.ROOT), createJobUsageEntry( - jobCountByState.get(jobState).get(), - detectorStatsByState.get(jobState), - modelSizeStatsByState.get(jobState))); - } - } - - private Map createJobUsageEntry(long count, StatsAccumulator detectorStats, - StatsAccumulator modelSizeStats) { - Map usage = new HashMap<>(); - usage.put(COUNT, count); - usage.put(DETECTORS, detectorStats.asMap()); - usage.put(MODEL_SIZE, modelSizeStats.asMap()); - return usage; - } - - private void addDatafeedsUsage(GetDatafeedsStatsAction.Response response) { - Map datafeedCountByState = new HashMap<>(); - - List datafeedsStats = response.getResponse().results(); - for (DatafeedStats datafeedStats : datafeedsStats) { - datafeedCountByState.computeIfAbsent(datafeedStats.getDatafeedState(), - ds -> Counter.newCounter()).addAndGet(1); - } - - datafeedsUsage.put(ALL, createDatafeedUsageEntry(response.getResponse().count())); - for (DatafeedState datafeedState : datafeedCountByState.keySet()) { - datafeedsUsage.put(datafeedState.name().toLowerCase(Locale.ROOT), - createDatafeedUsageEntry(datafeedCountByState.get(datafeedState).get())); - } - } - - private Map createDatafeedUsageEntry(long count) { - Map usage = new HashMap<>(); - usage.put(COUNT, count); - return usage; - } - } - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningSecurityExtension.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningSecurityExtension.java deleted file mode 100644 index 99ac60ca30d..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearningSecurityExtension.java +++ /dev/null @@ -1,47 +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.ml; - -import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.SecurityExtension; -import org.elasticsearch.xpack.security.support.MetadataUtils; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class MachineLearningSecurityExtension implements SecurityExtension { - @Override - public Map getReservedRoles() { - Map roles = new HashMap<>(); - - roles.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)); - - roles.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)); - - return Collections.unmodifiableMap(roles); - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringSecurityExtension.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringSecurityExtension.java deleted file mode 100644 index acac36f0908..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringSecurityExtension.java +++ /dev/null @@ -1,79 +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.monitoring; - -import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction; -import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.SecurityExtension; -import org.elasticsearch.xpack.security.support.MetadataUtils; -import org.elasticsearch.xpack.security.user.KibanaUser; -import org.elasticsearch.xpack.security.user.LogstashSystemUser; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class MonitoringSecurityExtension implements SecurityExtension { - @Override - public Map getReservedRoles() { - Map roles = new HashMap<>(); - - roles.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)); - - roles.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)); - - // TODO(core-infra) put KibanaUser & LogstashSystemUser into a common place for the split and use them here - roles.put("logstash_system", - new RoleDescriptor(LogstashSystemUser.ROLE_NAME, - new String[]{"monitor", MonitoringBulkAction.NAME}, - null, - null, - MetadataUtils.DEFAULT_RESERVED_METADATA)); - - roles.put("kibana_system", - 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)); - - return Collections.unmodifiableMap(roles); - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/StackSecurityExtension.java b/plugin/src/main/java/org/elasticsearch/xpack/security/StackSecurityExtension.java deleted file mode 100644 index 3a6281a4810..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/StackSecurityExtension.java +++ /dev/null @@ -1,68 +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; - -import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.support.MetadataUtils; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class StackSecurityExtension implements SecurityExtension { - @Override - public Map getReservedRoles() { - Map roles = new HashMap<>(); - - roles.put("transport_client", - new RoleDescriptor("transport_client", - new String[] { "transport_client" }, - null, - null, - MetadataUtils.DEFAULT_RESERVED_METADATA)); - - roles.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)); - - roles.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 - roles.put("reporting_user", - new RoleDescriptor("reporting_user", - null, - null, - null, - MetadataUtils.DEFAULT_RESERVED_METADATA)); - - roles.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)); - - return Collections.unmodifiableMap(roles); - } -} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java b/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java deleted file mode 100644 index 408111c8744..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStore.java +++ /dev/null @@ -1,37 +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.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.authz.permission.Role; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -public class ReservedRolesStore { - - public static final Role SUPERUSER_ROLE = Role.builder(ClientReservedRoles.SUPERUSER_ROLE_DESCRIPTOR, null).build(); - - public Map usageStats() { - return Collections.emptyMap(); - } - - public RoleDescriptor roleDescriptor(String role) { - return ClientReservedRoles.RESERVED_ROLES.get(role); - } - - public Collection roleDescriptors() { - return ClientReservedRoles.RESERVED_ROLES.values(); - } - - public static Set names() { - return ClientReservedRoles.RESERVED_ROLES.keySet(); - } - -} - diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherSecurityExtension.java b/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherSecurityExtension.java deleted file mode 100644 index 0cb3ca50449..00000000000 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherSecurityExtension.java +++ /dev/null @@ -1,55 +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.watcher; - -import org.elasticsearch.xpack.security.authz.RoleDescriptor; -import org.elasticsearch.xpack.security.SecurityExtension; -import org.elasticsearch.xpack.security.support.MetadataUtils; -import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; -import org.elasticsearch.xpack.watcher.history.HistoryStore; -import org.elasticsearch.xpack.watcher.watch.Watch; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class WatcherSecurityExtension implements SecurityExtension { - @Override - public Map getReservedRoles() { - Map roles = new HashMap<>(); - - roles.put("watcher_admin", - new RoleDescriptor("watcher_admin", - new String[] { "manage_watcher" }, - new RoleDescriptor.IndicesPrivileges[] { - RoleDescriptor.IndicesPrivileges.builder() - .indices(Watch.INDEX, - TriggeredWatchStore.INDEX_NAME, - HistoryStore.INDEX_PREFIX + "*") - .privileges("read").build() - }, - null, - MetadataUtils.DEFAULT_RESERVED_METADATA)); - - roles.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(HistoryStore.INDEX_PREFIX + "*") - .privileges("read") - .build() - }, - null, - MetadataUtils.DEFAULT_RESERVED_METADATA)); - - return Collections.unmodifiableMap(roles); - } -} diff --git a/plugin/src/main/resources/META-INF/services/org.elasticsearch.xpack.security.SecurityExtension b/plugin/src/main/resources/META-INF/services/org.elasticsearch.xpack.security.SecurityExtension deleted file mode 100644 index 28fce4ed578..00000000000 --- a/plugin/src/main/resources/META-INF/services/org.elasticsearch.xpack.security.SecurityExtension +++ /dev/null @@ -1,5 +0,0 @@ -org.elasticsearch.xpack.logstash.LogstashSecurityExtension -org.elasticsearch.xpack.ml.MachineLearningSecurityExtension -org.elasticsearch.xpack.monitoring.MonitoringSecurityExtension -org.elasticsearch.xpack.security.StackSecurityExtension -org.elasticsearch.xpack.watcher.WatcherSecurityExtension diff --git a/plugin/src/main/resources/meta-plugin-descriptor.properties b/plugin/src/main/resources/meta-plugin-descriptor.properties new file mode 100644 index 00000000000..2e878c207ac --- /dev/null +++ b/plugin/src/main/resources/meta-plugin-descriptor.properties @@ -0,0 +1,21 @@ +# Elasticsearch meta plugin descriptor file +# This file must exist as 'meta-plugin-descriptor.properties' in a folder named `elasticsearch`. +# +### example meta plugin for "meta-foo" +# +# meta-foo.zip <-- zip file for the meta plugin, with this structure: +#|____elasticsearch/ +#| |____ <-- The plugin files for bundled_plugin_1 (the content of the elastisearch directory) +#| |____ <-- The plugin files for bundled_plugin_2 +#| |____ meta-plugin-descriptor.properties <-- example contents below: +# +# description=My meta plugin +# name=meta-foo +# +### mandatory elements for all meta plugins: +# +# 'description': simple summary of the meta plugin +description=Elasticsearch Expanded Pack Plugin +# +# 'name': the meta plugin name +name=x-pack \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/CompositeTestingXPackPlugin.java b/plugin/src/test/java/org/elasticsearch/xpack/CompositeTestingXPackPlugin.java new file mode 100644 index 00000000000..c3ade34d7b2 --- /dev/null +++ b/plugin/src/test/java/org/elasticsearch/xpack/CompositeTestingXPackPlugin.java @@ -0,0 +1,72 @@ +/* + * 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.common.settings.Settings; +import org.elasticsearch.license.LicenseService; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.xpack.deprecation.Deprecation; +import org.elasticsearch.xpack.graph.Graph; +import org.elasticsearch.xpack.logstash.Logstash; +import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; + + +import java.nio.file.Path; + +public class CompositeTestingXPackPlugin extends LocalStateCompositeXPackPlugin { + + public CompositeTestingXPackPlugin(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + CompositeTestingXPackPlugin thisVar = this; + plugins.add(new Deprecation()); + plugins.add(new Graph(settings)); + plugins.add(new Logstash(settings)); + plugins.add(new MachineLearning(settings, configPath) { + @Override + protected XPackLicenseState getLicenseState() { + return super.getLicenseState(); + } + }); + plugins.add(new Monitoring(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected LicenseService getLicenseService() { + return thisVar.getLicenseService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + }); + plugins.add(new Security(settings, configPath) { + @Override + protected SSLService getSslService() { return thisVar.getSslService(); } + + @Override + protected XPackLicenseState getLicenseState() { return thisVar.getLicenseState(); } + }); + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/TimeWarpedXPackPlugin.java b/plugin/src/test/java/org/elasticsearch/xpack/TimeWarpedXPackPlugin.java deleted file mode 100644 index 1fd51d6e064..00000000000 --- a/plugin/src/test/java/org/elasticsearch/xpack/TimeWarpedXPackPlugin.java +++ /dev/null @@ -1,35 +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; - -import org.bouncycastle.operator.OperatorCreationException; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.xpack.watcher.watch.clock.ClockMock; -import org.elasticsearch.xpack.watcher.test.TimeWarpedWatcher; - -import javax.security.auth.DestroyFailedException; -import java.io.IOException; -import java.nio.file.Path; -import java.security.GeneralSecurityException; -import java.time.Clock; - -public class TimeWarpedXPackPlugin extends XPackPlugin { - - // use a single clock across all nodes using this plugin, this lets keep it static - private static final ClockMock clock = new ClockMock(); - - public TimeWarpedXPackPlugin(Settings settings, Path configPath) throws IOException, - DestroyFailedException, OperatorCreationException, GeneralSecurityException { - super(settings, configPath); - watcher = new TimeWarpedWatcher(settings); - } - - @Override - protected Clock getClock() { - return clock; - } - -} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java index 3ac056c8ab4..b6b29d1f937 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/store/ReservedRolesStoreTests.java @@ -72,7 +72,7 @@ import org.elasticsearch.xpack.ml.action.ValidateDetectorAction; import org.elasticsearch.xpack.ml.action.ValidateJobConfigAction; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndexFields; -import org.elasticsearch.xpack.ml.notifications.Auditor; +import org.elasticsearch.xpack.ml.notifications.AuditorField; import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction; import org.elasticsearch.xpack.security.action.role.PutRoleAction; import org.elasticsearch.xpack.security.action.user.PutUserAction; @@ -82,8 +82,8 @@ import org.elasticsearch.xpack.security.authz.permission.FieldPermissionsCache; import org.elasticsearch.xpack.security.authz.permission.Role; import org.elasticsearch.xpack.security.user.SystemUser; import org.elasticsearch.xpack.security.user.XPackUser; -import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; 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; @@ -110,22 +110,22 @@ public class ReservedRolesStoreTests extends ESTestCase { private static final String READ_CROSS_CLUSTER_NAME = "internal:transport/proxy/indices:data/read/query"; public void testIsReserved() { - assertThat(ClientReservedRoles.isReserved("kibana_system"), is(true)); - assertThat(ClientReservedRoles.isReserved("superuser"), is(true)); - assertThat(ClientReservedRoles.isReserved("foobar"), is(false)); - assertThat(ClientReservedRoles.isReserved(SystemUser.ROLE_NAME), is(true)); - assertThat(ClientReservedRoles.isReserved("transport_client"), is(true)); - assertThat(ClientReservedRoles.isReserved("kibana_user"), is(true)); - assertThat(ClientReservedRoles.isReserved("ingest_admin"), is(true)); - assertThat(ClientReservedRoles.isReserved("remote_monitoring_agent"), is(true)); - assertThat(ClientReservedRoles.isReserved("monitoring_user"), is(true)); - assertThat(ClientReservedRoles.isReserved("reporting_user"), is(true)); - assertThat(ClientReservedRoles.isReserved("machine_learning_user"), is(true)); - assertThat(ClientReservedRoles.isReserved("machine_learning_admin"), is(true)); - assertThat(ClientReservedRoles.isReserved("watcher_user"), is(true)); - assertThat(ClientReservedRoles.isReserved("watcher_admin"), is(true)); - assertThat(ClientReservedRoles.isReserved("kibana_dashboard_only_user"), is(true)); - assertThat(ClientReservedRoles.isReserved(XPackUser.ROLE_NAME), is(true)); + assertThat(ReservedRolesStore.isReserved("kibana_system"), is(true)); + assertThat(ReservedRolesStore.isReserved("superuser"), is(true)); + assertThat(ReservedRolesStore.isReserved("foobar"), is(false)); + assertThat(ReservedRolesStore.isReserved(SystemUser.ROLE_NAME), is(true)); + assertThat(ReservedRolesStore.isReserved("transport_client"), is(true)); + assertThat(ReservedRolesStore.isReserved("kibana_user"), is(true)); + assertThat(ReservedRolesStore.isReserved("ingest_admin"), is(true)); + assertThat(ReservedRolesStore.isReserved("remote_monitoring_agent"), is(true)); + assertThat(ReservedRolesStore.isReserved("monitoring_user"), is(true)); + assertThat(ReservedRolesStore.isReserved("reporting_user"), is(true)); + assertThat(ReservedRolesStore.isReserved("machine_learning_user"), is(true)); + assertThat(ReservedRolesStore.isReserved("machine_learning_admin"), is(true)); + assertThat(ReservedRolesStore.isReserved("watcher_user"), is(true)); + assertThat(ReservedRolesStore.isReserved("watcher_admin"), is(true)); + assertThat(ReservedRolesStore.isReserved("kibana_dashboard_only_user"), is(true)); + assertThat(ReservedRolesStore.isReserved(XPackUser.ROLE_NAME), is(true)); } public void testIngestAdminRole() { @@ -508,7 +508,7 @@ public class ReservedRolesStoreTests extends ESTestCase { assertOnlyReadAllowed(role, MlMetaIndex.INDEX_NAME); assertOnlyReadAllowed(role, AnomalyDetectorsIndex.jobStateIndexName()); assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT); - assertOnlyReadAllowed(role, Auditor.NOTIFICATIONS_INDEX); + assertOnlyReadAllowed(role, AuditorField.NOTIFICATIONS_INDEX); } public void testMachineLearningUserRole() { @@ -558,7 +558,7 @@ public class ReservedRolesStoreTests extends ESTestCase { assertNoAccessAllowed(role, MlMetaIndex.INDEX_NAME); assertNoAccessAllowed(role, AnomalyDetectorsIndex.jobStateIndexName()); assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT); - assertOnlyReadAllowed(role, Auditor.NOTIFICATIONS_INDEX); + assertOnlyReadAllowed(role, AuditorField.NOTIFICATIONS_INDEX); } public void testWatcherAdminRole() { @@ -580,8 +580,8 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); DateTime now = DateTime.now(DateTimeZone.UTC); - String historyIndex = HistoryStore.getHistoryIndexNameForTime(now); - for (String index : new String[]{ Watch.INDEX, historyIndex, TriggeredWatchStore.INDEX_NAME }) { + String historyIndex = HistoryStoreField.getHistoryIndexNameForTime(now); + for (String index : new String[]{ Watch.INDEX, historyIndex, TriggeredWatchStoreField.INDEX_NAME }) { assertOnlyReadAllowed(role, index); } } @@ -603,10 +603,10 @@ public class ReservedRolesStoreTests extends ESTestCase { assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(TriggeredWatchStore.INDEX_NAME), is(false)); + assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(TriggeredWatchStoreField.INDEX_NAME), is(false)); DateTime now = DateTime.now(DateTimeZone.UTC); - String historyIndex = HistoryStore.getHistoryIndexNameForTime(now); + String historyIndex = HistoryStoreField.getHistoryIndexNameForTime(now); for (String index : new String[]{ Watch.INDEX, historyIndex }) { assertOnlyReadAllowed(role, index); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java b/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java index b30307bed0e..fd117b82336 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java @@ -13,15 +13,16 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.plugins.MetaDataUpgrader; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.xpack.ml.MlMetaIndex; import org.elasticsearch.xpack.ml.integration.MlRestTestStateCleaner; import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex; -import org.elasticsearch.xpack.ml.notifications.Auditor; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.ml.notifications.AuditorField; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.junit.After; import org.junit.Before; @@ -46,9 +47,8 @@ import static org.hamcrest.Matchers.is; /** Runs rest tests against external cluster */ public class XPackRestIT extends ESClientYamlSuiteTestCase { - private static final String BASIC_AUTH_VALUE = - basicAuthHeaderValue("x_pack_rest_user", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + basicAuthHeaderValue("x_pack_rest_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); public XPackRestIT(ClientYamlTestCandidate testCandidate) { super(testCandidate); @@ -80,9 +80,10 @@ public class XPackRestIT extends ESClientYamlSuiteTestCase { private void waitForTemplates() throws Exception { if (installTemplates()) { List templates = new ArrayList<>(); - templates.addAll(Arrays.asList(Auditor.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, AnomalyDetectorsIndex.jobStateIndexName(), + templates.addAll(Arrays.asList(AuditorField.NOTIFICATIONS_INDEX, MlMetaIndex.INDEX_NAME, + AnomalyDetectorsIndex.jobStateIndexName(), AnomalyDetectorsIndex.jobResultsIndexPrefix())); - templates.addAll(Arrays.asList(WatcherIndexTemplateRegistry.TEMPLATE_NAMES)); + templates.addAll(Arrays.asList(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES)); for (String template : templates) { awaitCallApi("indices.exists_template", singletonMap("name", template), emptyList(), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java deleted file mode 100644 index 9571404e55c..00000000000 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java +++ /dev/null @@ -1,72 +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.watcher.test; - -import org.apache.logging.log4j.Logger; -import org.elasticsearch.common.logging.ServerLoggers; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.watcher.Watcher; -import org.elasticsearch.xpack.watcher.execution.ExecutionService; -import org.elasticsearch.xpack.watcher.execution.SyncTriggerEventConsumer; -import org.elasticsearch.xpack.watcher.execution.WatchExecutor; -import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock; -import org.elasticsearch.xpack.watcher.trigger.TriggerEngine; -import org.elasticsearch.xpack.watcher.trigger.TriggerEvent; -import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry; - -import java.time.Clock; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.function.Consumer; -import java.util.stream.Stream; - -public class TimeWarpedWatcher extends Watcher { - - public TimeWarpedWatcher(Settings settings) { - super(settings); - Logger logger = ServerLoggers.getLogger(TimeWarpedWatcher.class, settings); - logger.info("using time warped watchers plugin"); - } - - @Override - protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { - return new ScheduleTriggerEngineMock(settings, scheduleRegistry, clock); - } - - @Override - protected WatchExecutor getWatchExecutor(ThreadPool threadPool) { - return new SameThreadExecutor(); - } - - @Override - protected Consumer> getTriggerEngineListener(ExecutionService executionService) { - return new SyncTriggerEventConsumer(settings, executionService); - } - - public static class SameThreadExecutor implements WatchExecutor { - - @Override - public Stream tasks() { - return Stream.empty(); - } - - @Override - public BlockingQueue queue() { - return new ArrayBlockingQueue<>(1); - } - - @Override - public long largestPoolSize() { - return 1; - } - - @Override - public void execute(Runnable runnable) { - runnable.run(); - } - } -} diff --git a/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml b/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml index ec037b42c1a..b1a6d5d80dd 100644 --- a/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml +++ b/plugin/src/test/resources/rest-api-spec/test/xpack/10_basic.yml @@ -8,4 +8,12 @@ - do: nodes.info: {} - - match: { nodes.$master.plugins.0.name: x-pack } + - match: { nodes.$master.plugins.0.name: x-pack-core } + - match: { nodes.$master.plugins.1.name: x-pack-deprecation } + - match: { nodes.$master.plugins.2.name: x-pack-graph } + - match: { nodes.$master.plugins.3.name: x-pack-logstash } + - match: { nodes.$master.plugins.4.name: x-pack-ml } + - match: { nodes.$master.plugins.5.name: x-pack-monitoring } + - match: { nodes.$master.plugins.6.name: x-pack-security } + - match: { nodes.$master.plugins.7.name: x-pack-upgrade } + - match: { nodes.$master.plugins.8.name: x-pack-watcher } diff --git a/plugin/upgrade/build.gradle b/plugin/upgrade/build.gradle new file mode 100644 index 00000000000..7795549c313 --- /dev/null +++ b/plugin/upgrade/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-upgrade' + description 'Elasticsearch Expanded Pack Plugin - Upgrade' + classname 'org.elasticsearch.xpack.upgrade.Upgrade' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} + +archivesBaseName = 'x-pack-upgrade' +// TODO: enable this once we have tests +test.enabled=false +licenseHeaders.enabled = false + +integTest.enabled = false + +dependencies { + provided "org.elasticsearch:elasticsearch:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') +} + +compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" +compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" + +dependencyLicenses { + ignoreSha 'x-pack-core' +} + +run { + plugin ':x-pack-elasticsearch:plugin:core' +} diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java similarity index 97% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java index 7a9f88e842f..d569b425761 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java +++ b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheck.java @@ -32,7 +32,6 @@ import java.util.function.Function; * - postUpgrade is called if reindex was successful */ public class IndexUpgradeCheck extends AbstractComponent { - public static final int UPRADE_VERSION = 6; private final String name; private final Function actionRequired; @@ -77,8 +76,8 @@ public class IndexUpgradeCheck extends AbstractComponent { super(settings); this.name = name; this.actionRequired = actionRequired; - this.reindexer = new InternalIndexReindexer<>(client, clusterService, UPRADE_VERSION, updateScript, types, preUpgrade, - postUpgrade); + this.reindexer = new InternalIndexReindexer<>(client, clusterService, IndexUpgradeCheckVersion.UPRADE_VERSION, updateScript, + types, preUpgrade, postUpgrade); } /** diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckFactory.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckFactory.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeCheckFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeService.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeService.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/IndexUpgradeService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexer.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexer.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java similarity index 85% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java index 03ef92a37a9..ac8df1b0cec 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java +++ b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/Upgrade.java @@ -13,17 +13,22 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; +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.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; 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.XPackClientPlugin; import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeAction; import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeInfoAction; import org.elasticsearch.xpack.upgrade.actions.TransportIndexUpgradeAction; @@ -39,14 +44,10 @@ import java.util.List; import java.util.function.BiFunction; import java.util.function.Supplier; -public class Upgrade implements ActionPlugin { +public class Upgrade extends Plugin implements ActionPlugin { public static final Version UPGRADE_INTRODUCED = Version.V_5_6_0; - // 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 final Settings settings; private final List> upgradeCheckFactories; @@ -55,9 +56,11 @@ public class Upgrade implements ActionPlugin { this.upgradeCheckFactories = new ArrayList<>(); } + @Override public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, - NamedXContentRegistry xContentRegistry) { + NamedXContentRegistry xContentRegistry, Environment environment, + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { List upgradeChecks = new ArrayList<>(upgradeCheckFactories.size()); for (BiFunction checkFactory : upgradeCheckFactories) { upgradeChecks.add(checkFactory.apply(client, clusterService)); @@ -84,10 +87,4 @@ public class Upgrade implements ActionPlugin { ); } - /** - * 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/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeAction.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeAction.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java similarity index 98% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java index 25a419fca1e..a9f8d8f3231 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java +++ b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/actions/TransportIndexUpgradeInfoAction.java @@ -19,7 +19,7 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.upgrade.IndexUpgradeService; import org.elasticsearch.xpack.upgrade.UpgradeActionRequired; @@ -68,7 +68,7 @@ public class TransportIndexUpgradeInfoAction extends TransportMasterNodeReadActi indexUpgradeService.upgradeInfo(request.indices(), request.indicesOptions(), state); listener.onResponse(new IndexUpgradeInfoAction.Response(results)); } else { - listener.onFailure(LicenseUtils.newComplianceException(XpackField.UPGRADE)); + listener.onFailure(LicenseUtils.newComplianceException(XPackField.UPGRADE)); } } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeAction.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeAction.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeInfoAction.java b/plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeInfoAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeInfoAction.java rename to plugin/upgrade/src/main/java/org/elasticsearch/xpack/upgrade/rest/RestIndexUpgradeInfoAction.java diff --git a/plugin/upgrade/src/main/plugin-metadata/plugin-security.policy b/plugin/upgrade/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/upgrade/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIT.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIT.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java index b9abf187317..1c06bc9d7fd 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java +++ b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeIntegTestCase.java @@ -15,7 +15,7 @@ import org.elasticsearch.license.TestUtils; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.monitoring.test.MockPainlessScriptEngine; import java.util.Arrays; @@ -30,7 +30,7 @@ public abstract class IndexUpgradeIntegTestCase extends AbstractLicensesIntegrat @Override protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal)); - settings.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + settings.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); @@ -42,7 +42,7 @@ public abstract class IndexUpgradeIntegTestCase extends AbstractLicensesIntegrat @Override protected Settings transportClientSettings() { Settings.Builder settings = Settings.builder().put(super.transportClientSettings()); - settings.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + settings.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeServiceTests.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeServiceTests.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java index 6c2877ff49a..f53bcec7184 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java +++ b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/IndexUpgradeTasksIT.java @@ -123,7 +123,7 @@ public class IndexUpgradeTasksIT extends ESIntegTestCase { @Override public UpgradeActionRequired apply(IndexMetaData indexMetaData) { if ("test".equals(indexMetaData.getIndex().getName())) { - if (Upgrade.checkInternalIndexFormat(indexMetaData)) { + if (UpgradeField.checkInternalIndexFormat(indexMetaData)) { return UpgradeActionRequired.UP_TO_DATE; } else { return UpgradeActionRequired.UPGRADE; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexerIT.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexerIT.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexerIT.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/InternalIndexReindexerIT.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeActionRequestTests.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeActionRequestTests.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionRequestTests.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionRequestTests.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionResponseTests.java b/plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionResponseTests.java rename to plugin/upgrade/src/test/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeInfoActionResponseTests.java diff --git a/plugin/watcher/build.gradle b/plugin/watcher/build.gradle index 4f4ccbe1c86..d5f38255473 100644 --- a/plugin/watcher/build.gradle +++ b/plugin/watcher/build.gradle @@ -1,11 +1,30 @@ -apply plugin: 'elasticsearch.build' +import org.elasticsearch.gradle.test.RunTask + +apply plugin: 'elasticsearch.esplugin' +esplugin { + name 'x-pack-watcher' + description 'Elasticsearch Expanded Pack Plugin - Watcher' + classname 'org.elasticsearch.xpack.watcher.Watcher' + hasNativeController true + requiresKeystore true + extendedPlugins = ['x-pack-core'] + licenseFile project(':x-pack-elasticsearch').file('LICENSE.txt') + noticeFile project(':x-pack-elasticsearch').file('NOTICE.txt') +} archivesBaseName = 'x-pack-watcher' // TODO: enable this once we have tests -test.enabled=false licenseHeaders.enabled = false +integTest.enabled = false + +// TODO: fix this! https://github.com/elastic/x-plugins/issues/1066 +ext.compactProfile = 'full' + +compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" +compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" + dependencyLicenses { mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer' ignoreSha 'x-pack-core' @@ -14,7 +33,11 @@ dependencyLicenses { dependencies { provided "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + provided "org.elasticsearch.plugin:x-pack-core:${version}" + provided project(path: ':modules:transport-netty4', configuration: 'runtime') + provided project(path: ':plugins:transport-nio', configuration: 'runtime') + + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') // watcher deps compile 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:r239' @@ -23,11 +46,12 @@ dependencies { // 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' + provided "org.apache.httpcomponents:httpclient:${versions.httpclient}" + provided "org.apache.httpcomponents:httpcore:${versions.httpcore}" -} - -parent.bundlePlugin { - from jar + testCompile 'org.subethamail:subethasmtp:3.1.7' + // needed for subethasmtp, has @GuardedBy annotation + testCompile 'com.google.code.findbugs:jsr305:3.0.1' } // classes are missing, e.g. com.ibm.icu.lang.UCharacter @@ -81,3 +105,29 @@ if (JavaVersion.current() <= JavaVersion.VERSION_1_8) { 'javax.activation.UnsupportedDataTypeException' ] } + +run { + plugin ':x-pack-elasticsearch:plugin:core' +} + +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' +} + +integTestRunner { + // TODO: this test was failing for the big split merge + def blacklist = ['watcher/execute_watch/*'] + systemProperty 'tests.rest.blacklist', blacklist.join(',') +} diff --git a/plugin/bin/x-pack/croneval b/plugin/watcher/src/main/bin/croneval similarity index 100% rename from plugin/bin/x-pack/croneval rename to plugin/watcher/src/main/bin/croneval diff --git a/plugin/bin/x-pack/croneval.bat b/plugin/watcher/src/main/bin/croneval.bat similarity index 100% rename from plugin/bin/x-pack/croneval.bat rename to plugin/watcher/src/main/bin/croneval.bat diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java similarity index 95% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java index 792658072d4..259ed7c5366 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheck.java @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.watcher; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.bootstrap.BootstrapContext; import org.elasticsearch.env.Environment; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import java.nio.file.Files; import java.nio.file.Path; @@ -25,7 +25,7 @@ final class EncryptSensitiveDataBootstrapCheck implements BootstrapCheck { public BootstrapCheckResult check(BootstrapContext context) { if (Watcher.ENCRYPT_SENSITIVE_DATA_SETTING.get(context.settings) && WatcherField.ENCRYPTION_KEY_SETTING.exists(context.settings) == false) { - final Path systemKeyPath = environment.configFile().resolve(XpackField.NAME).resolve("system_key").toAbsolutePath(); + final Path systemKeyPath = environment.configFile().resolve(XPackField.NAME).resolve("system_key").toAbsolutePath(); final String message; if (Files.exists(systemKeyPath)) { message = "Encryption of sensitive data requires the key to be placed in the secure setting store. Run " + diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java similarity index 91% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index ebe8676b8b5..477f43c94b1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -10,14 +10,11 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; -import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Booleans; -import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.util.Providers; @@ -34,9 +31,12 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexModule; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.plugins.ScriptPlugin; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.script.ExecutableScript; @@ -47,10 +47,10 @@ import org.elasticsearch.script.TemplateScript; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.watcher.ResourceWatcherService; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.watcher.actions.ActionFactory; import org.elasticsearch.xpack.watcher.actions.ActionRegistry; @@ -78,11 +78,11 @@ import org.elasticsearch.xpack.watcher.common.http.auth.HttpAuthRegistry; import org.elasticsearch.xpack.watcher.common.http.auth.basic.BasicAuth; import org.elasticsearch.xpack.watcher.common.http.auth.basic.BasicAuthFactory; import org.elasticsearch.xpack.watcher.common.text.TextTemplateEngine; -import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; import org.elasticsearch.xpack.watcher.condition.ArrayCompareCondition; import org.elasticsearch.xpack.watcher.condition.CompareCondition; import org.elasticsearch.xpack.watcher.condition.ConditionFactory; import org.elasticsearch.xpack.watcher.condition.ConditionRegistry; +import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; import org.elasticsearch.xpack.watcher.condition.NeverCondition; import org.elasticsearch.xpack.watcher.condition.ScriptCondition; import org.elasticsearch.xpack.watcher.crypto.CryptoService; @@ -91,8 +91,10 @@ import org.elasticsearch.xpack.watcher.execution.ExecutionService; import org.elasticsearch.xpack.watcher.execution.InternalWatchExecutor; import org.elasticsearch.xpack.watcher.execution.TriggeredWatch; import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.watcher.execution.WatchExecutor; import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.input.InputFactory; import org.elasticsearch.xpack.watcher.input.InputRegistry; import org.elasticsearch.xpack.watcher.input.chain.ChainInput; @@ -190,7 +192,7 @@ import java.util.function.UnaryOperator; import static java.util.Collections.emptyList; -public class Watcher implements ActionPlugin { +public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin { static { // some classes need to have their own clinit blocks @@ -220,39 +222,32 @@ public class Watcher implements ActionPlugin { private static final Logger logger = Loggers.getLogger(Watcher.class); private WatcherIndexingListener listener; - public List getNamedWriteables() { - List entries = new ArrayList<>(); - entries.add(new NamedWriteableRegistry.Entry(MetaData.Custom.class, WatcherMetaData.TYPE, WatcherMetaData::new)); - entries.add(new NamedWriteableRegistry.Entry(NamedDiff.class, WatcherMetaData.TYPE, WatcherMetaData::readDiffFrom)); - entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XpackField.WATCHER, WatcherFeatureSet.Usage::new)); - return entries; - } - - public List getNamedXContent() { - List entries = new ArrayList<>(); - // Metadata - entries.add(new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(WatcherMetaData.TYPE), - WatcherMetaData::fromXContent)); - return entries; - } - protected final Settings settings; protected final boolean transportClient; protected final boolean enabled; + protected final Environment env; - public Watcher(Settings settings) { + public Watcher(final Settings settings) { this.settings = settings; - this.enabled = XPackSettings.WATCHER_ENABLED.get(settings); this.transportClient = XPackPlugin.transportClientMode(settings); + this.enabled = XPackSettings.WATCHER_ENABLED.get(settings); + env = transportClient ? null : new Environment(settings, null); + if (enabled && transportClient == false) { validAutoCreateIndex(settings, logger); } } - public Collection createComponents(Clock clock, ScriptService scriptService, Client client, - XPackLicenseState licenseState, - ThreadPool threadPool, ClusterService clusterService, - NamedXContentRegistry xContentRegistry, SSLService sslService) { + // overridable by tests + protected SSLService getSslService() { return XPackPlugin.getSharedSslService(); } + protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); } + protected Clock getClock() { return Clock.systemUTC(); } + + @Override + public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, + ResourceWatcherService resourceWatcherService, ScriptService scriptService, + NamedXContentRegistry xContentRegistry, Environment environment, + NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { if (enabled == false) { return Collections.emptyList(); } @@ -272,7 +267,7 @@ public class Watcher implements ActionPlugin { // TODO: add more auth types, or remove this indirection HttpAuthRegistry httpAuthRegistry = new HttpAuthRegistry(httpAuthFactories); HttpRequestTemplate.Parser httpTemplateParser = new HttpRequestTemplate.Parser(httpAuthRegistry); - final HttpClient httpClient = new HttpClient(settings, httpAuthRegistry, sslService); + final HttpClient httpClient = new HttpClient(settings, httpAuthRegistry, getSslService()); // notification EmailService emailService = new EmailService(settings, cryptoService, clusterService.getClusterSettings()); @@ -298,7 +293,7 @@ public class Watcher implements ActionPlugin { parsers.put(CompareCondition.TYPE, CompareCondition::parse); parsers.put(ScriptCondition.TYPE, (c, id, p) -> ScriptCondition.parse(scriptService, id, p)); - final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), clock); + final ConditionRegistry conditionRegistry = new ConditionRegistry(Collections.unmodifiableMap(parsers), getClock()); final Map transformFactories = new HashMap<>(); transformFactories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService)); transformFactories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, xContentRegistry, scriptService)); @@ -314,7 +309,8 @@ public class Watcher implements ActionPlugin { actionFactoryMap.put(JiraAction.TYPE, new JiraActionFactory(settings, templateEngine, jiraService)); actionFactoryMap.put(SlackAction.TYPE, new SlackActionFactory(settings, templateEngine, slackService)); actionFactoryMap.put(PagerDutyAction.TYPE, new PagerDutyActionFactory(settings, templateEngine, pagerDutyService)); - final ActionRegistry registry = new ActionRegistry(actionFactoryMap, conditionRegistry, transformRegistry, clock, licenseState); + final ActionRegistry registry = new ActionRegistry(actionFactoryMap, conditionRegistry, transformRegistry, getClock(), + getLicenseState()); // inputs final Map inputFactories = new HashMap<>(); @@ -340,7 +336,7 @@ public class Watcher implements ActionPlugin { final ScheduleRegistry scheduleRegistry = new ScheduleRegistry(scheduleParsers); TriggerEngine manualTriggerEngine = new ManualTriggerEngine(); - final TriggerEngine configuredTriggerEngine = getTriggerEngine(clock, scheduleRegistry); + final TriggerEngine configuredTriggerEngine = getTriggerEngine(getClock(), scheduleRegistry); final Set triggerEngines = new HashSet<>(); triggerEngines.add(manualTriggerEngine); @@ -353,10 +349,10 @@ public class Watcher implements ActionPlugin { final WatcherSearchTemplateService watcherSearchTemplateService = new WatcherSearchTemplateService(settings, scriptService, xContentRegistry); final WatchExecutor watchExecutor = getWatchExecutor(threadPool); - final WatchParser watchParser = new WatchParser(settings, triggerService, registry, inputRegistry, cryptoService, clock); + final WatchParser watchParser = new WatchParser(settings, triggerService, registry, inputRegistry, cryptoService, getClock()); final ExecutionService executionService = new ExecutionService(settings, historyStore, triggeredWatchStore, watchExecutor, - clock, watchParser, clusterService, client); + getClock(), watchParser, clusterService, client); final Consumer> triggerEngineListener = getTriggerEngineListener(executionService); triggerService.register(triggerEngineListener); @@ -367,7 +363,7 @@ public class Watcher implements ActionPlugin { final WatcherLifeCycleService watcherLifeCycleService = new WatcherLifeCycleService(settings, threadPool, clusterService, watcherService); - listener = new WatcherIndexingListener(settings, watchParser, clock, triggerService); + listener = new WatcherIndexingListener(settings, watchParser, getClock(), triggerService); clusterService.addListener(listener); return Arrays.asList(registry, inputRegistry, historyStore, triggerService, triggeredWatchParser, @@ -387,8 +383,10 @@ public class Watcher implements ActionPlugin { return new AsyncTriggerEventConsumer(settings, executionService); } - public Collection nodeModules() { + @Override + public Collection createGuiceModules() { List modules = new ArrayList<>(); + modules.add(b -> b.bind(Clock.class).toInstance(getClock())); //currently assuming the only place clock is bound modules.add(b -> { XPackPlugin.bindFeatureSet(b, WatcherFeatureSet.class); if (transportClient || enabled == false) { @@ -399,10 +397,7 @@ public class Watcher implements ActionPlugin { return modules; } - public Settings additionalSettings() { - return Settings.EMPTY; - } - + @Override public List> getSettings() { List> settings = new ArrayList<>(); settings.add(INDEX_WATCHER_TEMPLATE_VERSION_SETTING); @@ -442,6 +437,7 @@ public class Watcher implements ActionPlugin { return settings; } + @Override public List> getExecutorBuilders(final Settings settings) { if (enabled) { final FixedExecutorBuilder builder = @@ -511,6 +507,7 @@ public class Watcher implements ActionPlugin { new RestExecuteWatchAction(settings, restController)); } + @Override public void onIndexModule(IndexModule module) { if (enabled == false || transportClient) { return; @@ -532,7 +529,7 @@ public class Watcher implements ActionPlugin { String errorMessage = LoggerMessageFormat.format("the [action.auto_create_index] setting value [{}] is too" + " restrictive. disable [action.auto_create_index] or set it to " + - "[{}, {}, {}*]", (Object) value, Watch.INDEX, TriggeredWatchStore.INDEX_NAME, HistoryStore.INDEX_PREFIX); + "[{}, {}, {}*]", (Object) value, Watch.INDEX, TriggeredWatchStoreField.INDEX_NAME, HistoryStoreField.INDEX_PREFIX); if (Booleans.isFalse(value)) { throw new IllegalArgumentException(errorMessage); } @@ -546,14 +543,14 @@ public class Watcher implements ActionPlugin { indices.add(".watches"); indices.add(".triggered_watches"); DateTime now = new DateTime(DateTimeZone.UTC); - indices.add(HistoryStore.getHistoryIndexNameForTime(now)); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusDays(1))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(1))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(2))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(3))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(4))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(5))); - indices.add(HistoryStore.getHistoryIndexNameForTime(now.plusMonths(6))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now)); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusDays(1))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(1))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(2))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(3))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(4))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(5))); + indices.add(HistoryStoreField.getHistoryIndexNameForTime(now.plusMonths(6))); for (String index : indices) { boolean matched = false; for (String match : matches) { @@ -585,6 +582,7 @@ public class Watcher implements ActionPlugin { } // These are all old templates from pre 6.0 era, that need to be deleted + @Override public UnaryOperator> getIndexTemplateMetaDataUpgrader() { return map -> { map.keySet().removeIf(name -> name.startsWith("watch_history_")); @@ -592,11 +590,13 @@ public class Watcher implements ActionPlugin { }; } - public List getBootstrapChecks(Environment env) { + @Override + public List getBootstrapChecks() { return Collections.singletonList(new EncryptSensitiveDataBootstrapCheck(env)); } - public Collection getSettingsFilter() { + @Override + public List getSettingsFilter() { List filters = new ArrayList<>(); filters.add("xpack.notification.email.account.*.smtp.password"); filters.add("xpack.notification.jira.account.*.password"); @@ -608,6 +608,7 @@ public class Watcher implements ActionPlugin { return filters; } + @Override public List getContexts() { return Arrays.asList(Watcher.SCRIPT_SEARCH_CONTEXT, Watcher.SCRIPT_EXECUTABLE_CONTEXT, Watcher.SCRIPT_TEMPLATE_CONTEXT); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherClientHelper.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherClientHelper.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherClientHelper.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherClientHelper.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java similarity index 54% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java index 01483834eac..cd1950d8240 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherFeatureSet.java @@ -5,21 +5,17 @@ */ package org.elasticsearch.xpack.watcher; -import java.io.IOException; import java.util.Collections; import java.util.Map; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; public class WatcherFeatureSet implements XPackFeatureSet { @@ -36,7 +32,7 @@ public class WatcherFeatureSet implements XPackFeatureSet { @Override public String name() { - return XpackField.WATCHER; + return XPackField.WATCHER; } @Override @@ -62,41 +58,8 @@ public class WatcherFeatureSet implements XPackFeatureSet { @Override public void usage(ActionListener listener) { listener.onResponse( - new Usage(available(), enabled(), watcherService != null ? watcherService.usageStats() : Collections.emptyMap())); + new WatcherFeatureSetUsage(available(), enabled(), + watcherService != null ? watcherService.usageStats() : Collections.emptyMap())); } - public static class Usage extends XPackFeatureSet.Usage { - - private final Map stats; - - public Usage(StreamInput in) throws IOException { - super(in); - stats = in.readMap(); - } - - public Usage(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/WatcherIndexingListener.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java similarity index 96% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java index d15175ac9cd..b48e6ae7e43 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleService.java @@ -21,8 +21,8 @@ import org.elasticsearch.common.component.LifecycleListener; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.upgrade.Upgrade; -import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; +import org.elasticsearch.xpack.upgrade.UpgradeField; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; import org.elasticsearch.xpack.watcher.watch.Watch; import org.elasticsearch.xpack.watcher.watch.WatchStoreUtils; @@ -172,12 +172,12 @@ public class WatcherLifeCycleService extends AbstractComponent implements Cluste } } else if (watcherService.state() != WatcherState.STARTED && watcherService.state() != WatcherState.STARTING) { IndexMetaData watcherIndexMetaData = WatchStoreUtils.getConcreteIndex(Watch.INDEX, event.state().metaData()); - IndexMetaData triggeredWatchesIndexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStore.INDEX_NAME, + IndexMetaData triggeredWatchesIndexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStoreField.INDEX_NAME, event.state().metaData()); boolean isIndexInternalFormatWatchIndex = watcherIndexMetaData == null || - Upgrade.checkInternalIndexFormat(watcherIndexMetaData); + UpgradeField.checkInternalIndexFormat(watcherIndexMetaData); boolean isIndexInternalFormatTriggeredWatchIndex = triggeredWatchesIndexMetaData == null || - Upgrade.checkInternalIndexFormat(triggeredWatchesIndexMetaData); + UpgradeField.checkInternalIndexFormat(triggeredWatchesIndexMetaData); if (isIndexInternalFormatTriggeredWatchIndex && isIndexInternalFormatWatchIndex) { executor.execute(() -> start(event.state(), false)); } else { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/ActionBuilders.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/ActionBuilders.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/ActionBuilders.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/ActionBuilders.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/email/ExecutableEmailAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/ExecutableHipChatAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/ExecutableHipChatAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/ExecutableHipChatAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/ExecutableHipChatAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/ExecutableLoggingAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/ExecutableLoggingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/ExecutableLoggingAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/ExecutableLoggingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingLevel.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingLevel.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingLevel.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingLevel.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/ExecutablePagerDutyAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/ExecutablePagerDutyAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/ExecutablePagerDutyAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/ExecutablePagerDutyAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/ExecutableWebhookAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/ExecutableWebhookAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/ExecutableWebhookAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/ExecutableWebhookAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/client/WatchSourceBuilders.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/client/WatchSourceBuilders.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/client/WatchSourceBuilders.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/client/WatchSourceBuilders.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpClient.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpClient.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpClient.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpClient.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpContentType.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpContentType.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpContentType.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpContentType.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpMethod.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpMethod.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpMethod.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpMethod.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpProxy.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpProxy.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpProxy.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpProxy.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequest.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplate.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplate.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplate.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplate.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpResponse.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpResponse.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpResponse.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpResponse.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpSettings.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpSettings.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpSettings.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/HttpSettings.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/Scheme.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/Scheme.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/Scheme.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/Scheme.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStream.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStream.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStream.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStream.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/ApplicableHttpAuth.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/ApplicableHttpAuth.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/ApplicableHttpAuth.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/ApplicableHttpAuth.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuth.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuth.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuth.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuth.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthRegistry.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthRegistry.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthRegistry.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/HttpAuthRegistry.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/ApplicableBasicAuth.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/ApplicableBasicAuth.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/ApplicableBasicAuth.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/ApplicableBasicAuth.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuth.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuth.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuth.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuth.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuthFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuthFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuthFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/http/auth/basic/BasicAuthFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/stats/Counters.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/stats/Counters.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/stats/Counters.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/stats/Counters.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplate.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplate.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplate.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplate.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateEngine.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateEngine.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/AbstractCompareCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/AbstractCompareCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/AbstractCompareCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/AbstractCompareCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/CompareCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/CompareCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/CompareCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/CompareCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/InternalAlwaysCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/InternalAlwaysCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/InternalAlwaysCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/InternalAlwaysCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/LenientCompare.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/NeverCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/NeverCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/NeverCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/NeverCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/ScriptCondition.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/ScriptCondition.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/condition/ScriptCondition.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/ScriptCondition.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/AsyncTriggerEventConsumer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/CurrentExecutions.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/CurrentExecutions.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/CurrentExecutions.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/CurrentExecutions.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ExecutionService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java similarity index 92% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java index 46377cf8010..08de680de10 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/InternalWatchExecutor.java @@ -7,14 +7,14 @@ package org.elasticsearch.xpack.watcher.execution; import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import java.util.concurrent.BlockingQueue; import java.util.stream.Stream; public class InternalWatchExecutor implements WatchExecutor { - public static final String THREAD_POOL_NAME = XpackField.WATCHER; + public static final String THREAD_POOL_NAME = XPackField.WATCHER; private final ThreadPool threadPool; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/ManualExecutionContext.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ManualExecutionContext.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/ManualExecutionContext.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/ManualExecutionContext.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/SyncTriggerEventConsumer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredExecutionContext.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredExecutionContext.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredExecutionContext.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredExecutionContext.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatch.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatch.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatch.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatch.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java similarity index 92% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java index 1fab51640c9..bd933655dd5 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStore.java @@ -53,9 +53,6 @@ import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalState; public class TriggeredWatchStore extends AbstractComponent { - public static final String INDEX_NAME = ".triggered_watches"; - public static final String DOC_TYPE = "doc"; - private final int scrollSize; private final Client client; private final TimeValue scrollTimeout; @@ -82,7 +79,7 @@ public class TriggeredWatchStore extends AbstractComponent { public boolean validate(ClusterState state) { try { - IndexMetaData indexMetaData = WatchStoreUtils.getConcreteIndex(INDEX_NAME, state.metaData()); + IndexMetaData indexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStoreField.INDEX_NAME, state.metaData()); if (indexMetaData == null) { return true; } else { @@ -95,7 +92,8 @@ public class TriggeredWatchStore extends AbstractComponent { } } } catch (IllegalStateException e) { - logger.trace((Supplier) () -> new ParameterizedMessage("error getting index meta data [{}]: ", INDEX_NAME), e); + logger.trace((Supplier) () -> new ParameterizedMessage("error getting index meta data [{}]: ", + TriggeredWatchStoreField.INDEX_NAME), e); return false; } } @@ -111,8 +109,8 @@ public class TriggeredWatchStore extends AbstractComponent { } ensureStarted(); - executeAsyncWithOrigin(client.threadPool().getThreadContext(), WATCHER_ORIGIN, createBulkRequest(triggeredWatches, DOC_TYPE), - listener, client::bulk); + executeAsyncWithOrigin(client.threadPool().getThreadContext(), WATCHER_ORIGIN, createBulkRequest(triggeredWatches, + TriggeredWatchStoreField.DOC_TYPE), listener, client::bulk); } public BulkResponse putAll(final List triggeredWatches) throws IOException { @@ -131,7 +129,7 @@ public class TriggeredWatchStore extends AbstractComponent { private BulkRequest createBulkRequest(final List triggeredWatches, String docType) throws IOException { BulkRequest request = new BulkRequest(); for (TriggeredWatch triggeredWatch : triggeredWatches) { - IndexRequest indexRequest = new IndexRequest(INDEX_NAME, docType, triggeredWatch.id().value()); + IndexRequest indexRequest = new IndexRequest(TriggeredWatchStoreField.INDEX_NAME, docType, triggeredWatch.id().value()); try (XContentBuilder builder = XContentFactory.jsonBuilder()) { triggeredWatch.toXContent(builder, ToXContent.EMPTY_PARAMS); indexRequest.source(builder); @@ -144,7 +142,7 @@ public class TriggeredWatchStore extends AbstractComponent { public void delete(Wid wid) { ensureStarted(); - DeleteRequest request = new DeleteRequest(INDEX_NAME, DOC_TYPE, wid.value()); + DeleteRequest request = new DeleteRequest(TriggeredWatchStoreField.INDEX_NAME, TriggeredWatchStoreField.DOC_TYPE, wid.value()); try (ThreadContext.StoredContext ignore = stashWithOrigin(client.threadPool().getThreadContext(), WATCHER_ORIGIN)) { client.delete(request); // FIXME shouldn't we wait before saying the delete was successful } @@ -172,13 +170,14 @@ public class TriggeredWatchStore extends AbstractComponent { } // non existing index, return immediately - IndexMetaData indexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStore.INDEX_NAME, clusterState.metaData()); + IndexMetaData indexMetaData = WatchStoreUtils.getConcreteIndex(TriggeredWatchStoreField.INDEX_NAME, clusterState.metaData()); if (indexMetaData == null) { return Collections.emptyList(); } try (ThreadContext.StoredContext ignore = stashWithOrigin(client.threadPool().getThreadContext(), WATCHER_ORIGIN)) { - client.admin().indices().refresh(new RefreshRequest(TriggeredWatchStore.INDEX_NAME)).actionGet(TimeValue.timeValueSeconds(5)); + client.admin().indices().refresh(new RefreshRequest(TriggeredWatchStoreField.INDEX_NAME)) + .actionGet(TimeValue.timeValueSeconds(5)); } catch (IndexNotFoundException e) { return Collections.emptyList(); } @@ -186,7 +185,7 @@ public class TriggeredWatchStore extends AbstractComponent { Set ids = watches.stream().map(Watch::id).collect(Collectors.toSet()); Collection triggeredWatches = new ArrayList<>(ids.size()); - SearchRequest searchRequest = new SearchRequest(TriggeredWatchStore.INDEX_NAME) + SearchRequest searchRequest = new SearchRequest(TriggeredWatchStoreField.INDEX_NAME) .scroll(scrollTimeout) .preference(Preference.LOCAL.toString()) .source(new SearchSourceBuilder() diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutor.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutor.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutor.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/execution/WatchExecutor.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java similarity index 87% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java index ef98b439f3e..5f95c1143e1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/history/HistoryStore.java @@ -18,13 +18,10 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.engine.VersionConflictEngineException; import org.elasticsearch.xpack.watcher.execution.ExecutionState; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams; import org.elasticsearch.xpack.watcher.watch.WatchStoreUtils; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; import java.io.IOException; import java.util.concurrent.ExecutionException; @@ -41,12 +38,8 @@ import static org.elasticsearch.xpack.watcher.support.Exceptions.ioException; public class HistoryStore extends AbstractComponent { - public static final String INDEX_PREFIX = ".watcher-history-"; - public static final String INDEX_PREFIX_WITH_TEMPLATE = INDEX_PREFIX + WatcherIndexTemplateRegistry.INDEX_TEMPLATE_VERSION + "-"; public static final String DOC_TYPE = "doc"; - static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd"); - private final Client client; private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); @@ -80,7 +73,7 @@ public class HistoryStore extends AbstractComponent { if (!started.get()) { throw new IllegalStateException("unable to persist watch record history store is not ready"); } - String index = getHistoryIndexNameForTime(watchRecord.triggerEvent().triggeredTime()); + String index = HistoryStoreField.getHistoryIndexNameForTime(watchRecord.triggerEvent().triggeredTime()); putUpdateLock.lock(); try (XContentBuilder builder = XContentFactory.jsonBuilder(); ThreadContext.StoredContext ignore = stashWithOrigin(client.threadPool().getThreadContext(), WATCHER_ORIGIN)) { @@ -106,7 +99,7 @@ public class HistoryStore extends AbstractComponent { if (!started.get()) { throw new IllegalStateException("unable to persist watch record history store is not ready"); } - String index = getHistoryIndexNameForTime(watchRecord.triggerEvent().triggeredTime()); + String index = HistoryStoreField.getHistoryIndexNameForTime(watchRecord.triggerEvent().triggeredTime()); putUpdateLock.lock(); try { try (XContentBuilder builder = XContentFactory.jsonBuilder(); @@ -137,13 +130,6 @@ public class HistoryStore extends AbstractComponent { } } - /** - * Calculates the correct history index name for a given time - */ - public static String getHistoryIndexNameForTime(DateTime time) { - return INDEX_PREFIX_WITH_TEMPLATE + indexTimeFormat.print(time); - } - /** * Check if everything is set up for the history store to operate fully. Checks for the * current watcher history index and if it is open. @@ -152,7 +138,7 @@ public class HistoryStore extends AbstractComponent { * @return true, if history store is ready to be started */ public static boolean validate(ClusterState state) { - String currentIndex = getHistoryIndexNameForTime(DateTime.now(DateTimeZone.UTC)); + String currentIndex = HistoryStoreField.getHistoryIndexNameForTime(DateTime.now(DateTimeZone.UTC)); IndexMetaData indexMetaData = WatchStoreUtils.getConcreteIndex(currentIndex, state.metaData()); if (indexMetaData == null) { return true; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputBuilders.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputBuilders.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputBuilders.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputBuilders.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/InputRegistry.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/ExecutableHttpInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/http/HttpInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/none/ExecutableNoneInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/ExecutableNoneInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/none/ExecutableNoneInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/ExecutableNoneInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/none/NoneInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/ExecutableSearchInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/ExecutableSearchInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/ExecutableSearchInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/ExecutableSearchInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/search/SearchInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/ExecutableSimpleInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/ExecutableSimpleInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/ExecutableSimpleInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/ExecutableSimpleInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/ExecutableTransformInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInput.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInput.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInput.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInput.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/NotificationService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/NotificationService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/NotificationService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/NotificationService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Account.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Account.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Account.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Account.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Attachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Attachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Attachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Attachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Authentication.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Authentication.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Authentication.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Authentication.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplate.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplate.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplate.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplate.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizer.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizer.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Profile.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Profile.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Profile.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Profile.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachments.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentsParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpRequestAttachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpRequestAttachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpRequestAttachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpRequestAttachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/support/BodyPartSource.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/support/BodyPartSource.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/email/support/BodyPartSource.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/support/BodyPartSource.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessage.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServer.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServer.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServer.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServer.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/SentMessages.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/SentMessages.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/SentMessages.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/SentMessages.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1Account.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1Account.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1Account.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1Account.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssue.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssue.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssue.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssue.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/jira/JiraService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEvent.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEvent.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEvent.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEvent.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventContext.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventContext.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventContext.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventContext.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaults.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaults.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaults.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaults.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/pagerduty/SentEvent.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SentMessages.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SentMessages.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SentMessages.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SentMessages.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackAccount.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackAccount.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackAccount.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackAccount.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/SlackService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Action.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Action.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Action.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Action.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Attachment.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Attachment.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Attachment.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Attachment.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/DynamicAttachments.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Field.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Field.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Field.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/Field.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/MessageElement.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/MessageElement.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/MessageElement.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/MessageElement.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessage.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessage.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessage.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessage.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaults.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaults.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaults.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaults.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/ArrayObjectIterator.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/ArrayObjectIterator.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/ArrayObjectIterator.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/ArrayObjectIterator.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/Strings.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/Strings.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/Strings.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/Strings.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/Variables.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/Variables.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/Variables.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/Variables.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java similarity index 84% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java index 465ce1a7e6d..f20f0b485bc 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistry.java @@ -35,26 +35,12 @@ import static org.elasticsearch.xpack.ClientHelper.executeAsyncWithOrigin; public class WatcherIndexTemplateRegistry extends AbstractComponent implements ClusterStateListener { - // 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 - }; - - public static final TemplateConfig TEMPLATE_CONFIG_TRIGGERED_WATCHES = new TemplateConfig(TRIGGERED_TEMPLATE_NAME, "triggered-watches"); - public static final TemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY = new TemplateConfig(HISTORY_TEMPLATE_NAME, "watch-history"); - public static final TemplateConfig TEMPLATE_CONFIG_WATCHES = new TemplateConfig(WATCHES_TEMPLATE_NAME, "watches"); + public static final TemplateConfig TEMPLATE_CONFIG_TRIGGERED_WATCHES = new TemplateConfig( + WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, "triggered-watches"); + public static final TemplateConfig TEMPLATE_CONFIG_WATCH_HISTORY = new TemplateConfig( + WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME, "watch-history"); + public static final TemplateConfig TEMPLATE_CONFIG_WATCHES = new TemplateConfig( + WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME, "watches"); public static final TemplateConfig[] TEMPLATE_CONFIGS = new TemplateConfig[]{ TEMPLATE_CONFIG_TRIGGERED_WATCHES, TEMPLATE_CONFIG_WATCH_HISTORY, TEMPLATE_CONFIG_WATCHES }; @@ -140,9 +126,9 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C } public static boolean validate(ClusterState state) { - return state.getMetaData().getTemplates().containsKey(HISTORY_TEMPLATE_NAME) && - state.getMetaData().getTemplates().containsKey(TRIGGERED_TEMPLATE_NAME) && - state.getMetaData().getTemplates().containsKey(WATCHES_TEMPLATE_NAME); + return state.getMetaData().getTemplates().containsKey(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME) && + state.getMetaData().getTemplates().containsKey(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME) && + state.getMetaData().getTemplates().containsKey(WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME); } public static class TemplateConfig { @@ -164,7 +150,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C } public byte[] load() { - String template = TemplateUtils.loadTemplate("/" + fileName + ".json", INDEX_TEMPLATE_VERSION, + String template = TemplateUtils.loadTemplate("/" + fileName + ".json", WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION, Pattern.quote("${xpack.watcher.template.version}")); assert template != null && template.length() > 0; return template.getBytes(StandardCharsets.UTF_8); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/XContentFilterKeysUtils.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/XContentFilterKeysUtils.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/XContentFilterKeysUtils.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/XContentFilterKeysUtils.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ExecutableScriptTransform.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransform.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransform.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransform.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransform.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/ExecutableSearchTransform.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/ExecutableSearchTransform.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/ExecutableSearchTransform.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/ExecutableSearchTransform.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransform.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransform.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransform.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransform.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransformFactory.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransformFactory.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransformFactory.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/search/SearchTransformFactory.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java similarity index 96% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java index d9676559348..2bca462774a 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/WatcherTransportAction.java @@ -18,7 +18,7 @@ import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; public abstract class WatcherTransportAction extends HandledTransportAction { @@ -41,7 +41,7 @@ public abstract class WatcherTransportAction listener, Watch watch, boolean knownWatch) { - threadPool.executor(XpackField.WATCHER).submit(() -> { + threadPool.executor(XPackField.WATCHER).submit(() -> { try { // ensure that the headers from the incoming request are used instead those of the stored watch // otherwise the watch would run as the user who stored the watch, but it needs to be run as the user who diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/TransportGetWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/TransportGetWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/TransportGetWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/get/TransportGetWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/stats/TransportWatcherStatsAction.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/stats/TransportWatcherStatsAction.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/stats/TransportWatcherStatsAction.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/stats/TransportWatcherStatsAction.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerBuilders.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerBuilders.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerBuilders.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerBuilders.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerEngine.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerEngine.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/TriggerService.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTrigger.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTrigger.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTrigger.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTrigger.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEngine.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEngine.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEvent.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEvent.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEvent.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/manual/ManualTriggerEvent.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Cron.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Cron.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Cron.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Cron.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronSchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronSchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronSchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronSchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronnableSchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronnableSchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronnableSchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronnableSchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailySchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailySchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailySchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailySchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlySchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlySchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlySchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlySchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalSchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalSchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalSchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalSchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlySchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlySchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlySchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlySchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistry.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTrigger.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTrigger.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTrigger.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTrigger.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEngine.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEngine.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEvent.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEvent.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEvent.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEvent.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedules.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedules.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedules.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/Schedules.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklySchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklySchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklySchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklySchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlySchedule.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlySchedule.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlySchedule.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlySchedule.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleTriggerEngine.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayOfWeek.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayOfWeek.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayOfWeek.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayOfWeek.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Month.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Month.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Month.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Month.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/MonthTimes.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/MonthTimes.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/MonthTimes.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/MonthTimes.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Times.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Times.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Times.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/Times.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/WeekTimes.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/WeekTimes.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/WeekTimes.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/WeekTimes.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/YearTimes.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/YearTimes.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/YearTimes.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/YearTimes.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchParser.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchStoreUtils.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchStoreUtils.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchStoreUtils.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/WatchStoreUtils.java diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/clock/HaltedClock.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/clock/HaltedClock.java similarity index 100% rename from plugin/src/main/java/org/elasticsearch/xpack/watcher/watch/clock/HaltedClock.java rename to plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/watch/clock/HaltedClock.java diff --git a/plugin/watcher/src/main/plugin-metadata/plugin-security.policy b/plugin/watcher/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 00000000000..45d92fd2b8a --- /dev/null +++ b/plugin/watcher/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,50 @@ +grant { + // needed because of problems in unbound LDAP library + permission java.util.PropertyPermission "*", "read,write"; + + // required to configure the custom mailcap for watcher + permission java.lang.RuntimePermission "setFactory"; + + // needed when sending emails for javax.activation + // otherwise a classnotfound exception is thrown due to trying + // to load the class with the application class loader + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "getClassLoader"; + // TODO: remove use of this jar as soon as possible!!!! + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.activation.registries"; + + // bouncy castle + permission java.security.SecurityPermission "putProviderProperty.BC"; + + // needed for x-pack security extension + permission java.security.SecurityPermission "createPolicy.JavaPolicy"; + permission java.security.SecurityPermission "getPolicy"; + permission java.security.SecurityPermission "setPolicy"; + + // needed for multiple server implementations used in tests + permission java.net.SocketPermission "*", "accept,connect"; + + // needed for Windows named pipes in machine learning + permission java.io.FilePermission "\\\\.\\pipe\\*", "read,write"; +}; + +grant codeBase "${codebase.netty-common}" { + // for reading the system-wide configuration for the backlog of established sockets + permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read"; +}; + +grant codeBase "${codebase.netty-transport}" { + // Netty NioEventLoop wants to change this, because of https://bugs.openjdk.java.net/browse/JDK-6427854 + // the bug says it only happened rarely, and that its fixed, but apparently it still happens rarely! + permission java.util.PropertyPermission "sun.nio.ch.bugLevel", "write"; +}; + +grant codeBase "${codebase.elasticsearch-rest-client}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; + +grant codeBase "${codebase.httpasyncclient}" { + // rest client uses system properties which gets the default proxy + permission java.net.NetPermission "getProxySelector"; +}; \ No newline at end of file diff --git a/plugin/src/test/java/org/elasticsearch/xpack/notification/NotificationServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/notification/NotificationServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/notification/NotificationServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/notification/NotificationServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheckTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheckTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheckTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/EncryptSensitiveDataBootstrapCheckTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherClientHelperTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherClientHelperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherClientHelperTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherClientHelperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java index 756a2370107..5151d78a053 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherFeatureSetTests.java @@ -69,7 +69,7 @@ public class WatcherFeatureSetTests extends ESTestCase { XPackFeatureSet.Usage watcherUsage = future.get(); BytesStreamOutput out = new BytesStreamOutput(); watcherUsage.writeTo(out); - XPackFeatureSet.Usage serializedUsage = new WatcherFeatureSet.Usage(out.bytes().streamInput()); + XPackFeatureSet.Usage serializedUsage = new WatcherFeatureSetUsage(out.bytes().streamInput()); for (XPackFeatureSet.Usage usage : Arrays.asList(watcherUsage, serializedUsage)) { XContentBuilder builder = jsonBuilder(); @@ -78,8 +78,8 @@ public class WatcherFeatureSetTests extends ESTestCase { XContentSource source = new XContentSource(builder); assertThat(source.getValue("foo"), is("bar")); - assertThat(usage, instanceOf(WatcherFeatureSet.Usage.class)); - WatcherFeatureSet.Usage featureSetUsage = (WatcherFeatureSet.Usage) usage; + assertThat(usage, instanceOf(WatcherFeatureSetUsage.class)); + WatcherFeatureSetUsage featureSetUsage = (WatcherFeatureSetUsage) usage; assertThat(featureSetUsage.stats(), hasEntry("foo", "bar")); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherIndexingListenerTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherIndexingListenerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherIndexingListenerTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherIndexingListenerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java index d9df8302f59..a0d3fce4816 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherLifeCycleServiceTests.java @@ -32,6 +32,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.watcher.watch.Watch; import org.junit.Before; import org.mockito.stubbing.Answer; @@ -46,9 +47,9 @@ import java.util.stream.IntStream; import static java.util.Arrays.asList; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.WATCHES_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; @@ -402,7 +403,7 @@ public class WatcherLifeCycleServiceTests extends ESTestCase { } public void testWatcherDoesNotStartWithOldIndexFormat() throws Exception { - String index = randomFrom(Watch.INDEX, TriggeredWatchStore.INDEX_NAME); + String index = randomFrom(Watch.INDEX, TriggeredWatchStoreField.INDEX_NAME); Index watchIndex = new Index(index, "foo"); ShardId shardId = new ShardId(watchIndex, 0); IndexRoutingTable watchRoutingTable = IndexRoutingTable.builder(watchIndex) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java similarity index 92% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java index 0a182d36533..e00966862a1 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherMetaDataSerializationTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.XPackClientPlugin; import java.util.Collections; import java.util.stream.Collectors; @@ -40,7 +41,8 @@ public class WatcherMetaDataSerializationTests extends ESTestCase { } public void testWatcherMetadataParsingDoesNotSwallowOtherMetaData() throws Exception { - new Watcher(Settings.EMPTY); // makes sure WatcherMetaData is registered in Custom MetaData + Settings settings = Settings.builder().put("path.home", createTempDir()).build(); + new Watcher(settings); // makes sure WatcherMetaData is registered in Custom MetaData boolean manuallyStopped = randomBoolean(); WatcherMetaData watcherMetaData = new WatcherMetaData(manuallyStopped); RepositoryMetaData repositoryMetaData = new RepositoryMetaData("repo", "fs", Settings.EMPTY); @@ -79,7 +81,7 @@ public class WatcherMetaDataSerializationTests extends ESTestCase { @Override protected NamedXContentRegistry xContentRegistry() { return new NamedXContentRegistry(Stream.concat( - new Watcher(Settings.EMPTY).getNamedXContent().stream(), + new XPackClientPlugin(Settings.builder().put("path.home", createTempDir()).build()).getNamedXContent().stream(), ClusterModule.getNamedXWriteables().stream() ).collect(Collectors.toList())); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java index db00983e415..d0bebbbd51e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java @@ -51,7 +51,7 @@ public class WatcherPluginTests extends ESTestCase { assertThat(exception.getMessage(), containsString("[.watches, .triggered_watches, .watcher-history-*]")); } - public void testWatcherDisabledTests() { + public void testWatcherDisabledTests() throws Exception { Settings settings = Settings.builder() .put("xpack.watcher.enabled", false) .put("path.home", createTempDir()) @@ -60,7 +60,7 @@ public class WatcherPluginTests extends ESTestCase { List> executorBuilders = watcher.getExecutorBuilders(settings); assertThat(executorBuilders, hasSize(0)); - assertThat(watcher.nodeModules(), hasSize(1)); + assertThat(watcher.createGuiceModules(), hasSize(2)); assertThat(watcher.getActions(), hasSize(0)); assertThat(watcher.getRestHandlers(settings, null, null, null, null, null, null), hasSize(0)); @@ -73,7 +73,7 @@ public class WatcherPluginTests extends ESTestCase { watcher.onIndexModule(indexModule); // also no component creation if not enabled - assertThat(watcher.createComponents(null, null, null, null, null, null, null, null), hasSize(0)); + assertThat(watcher.createComponents(null, null, null, null, null, null, null, null, null), hasSize(0)); } public void testThreadPoolSize() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionErrorIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionErrorIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionErrorIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionErrorIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/ActionWrapperTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java index 056179885bd..78ba1756d98 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/TimeThrottleIntegrationTests.java @@ -12,7 +12,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.junit.annotations.TestLogging; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchResponse; @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.is; "org.elasticsearch.xpack.watcher.WatcherIndexingListener:TRACE") public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTestCase { - public void testTimeThrottle() throws Exception { + public void testTimeThrottle(){ String id = randomAlphaOfLength(20); PutWatchResponse putWatchResponse = watcherClient().preparePutWatch() .setId(id) @@ -61,7 +61,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest assertTotalHistoryEntries(id, 3); } - public void testTimeThrottleDefaults() throws Exception { + public void testTimeThrottleDefaults() { String id = randomAlphaOfLength(30); PutWatchResponse putWatchResponse = watcherClient().preparePutWatch() .setId(id) @@ -99,9 +99,9 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest } private Map assertLatestHistoryEntry(String id) { - refresh(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*"); + refresh(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*"); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setSize(1) .setSource(new SearchSourceBuilder().query(QueryBuilders.boolQuery() .must(termQuery("watch_id", id)))) @@ -115,7 +115,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest } private void assertTotalHistoryEntries(String id, long expectedCount) { - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setSize(0) .setSource(new SearchSourceBuilder().query(QueryBuilders.boolQuery().must(termQuery("watch_id", id)))) .get(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java index e4d6046d7f9..ce7fb2287f9 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/email/EmailAttachmentTests.java @@ -19,7 +19,7 @@ import org.elasticsearch.xpack.watcher.client.WatcherClient; import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.common.http.Scheme; import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.notification.email.EmailTemplate; import org.elasticsearch.xpack.watcher.notification.email.attachment.DataAttachment; import org.elasticsearch.xpack.watcher.notification.email.attachment.EmailAttachmentParser; @@ -184,7 +184,7 @@ public class EmailAttachmentTests extends AbstractWatcherIntegrationTestCase { timeWarp().trigger("_test_id"); refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setQuery(QueryBuilders.termQuery("watch_id", "_test_id")) .execute().actionGet(); assertHitCount(searchResponse, 1); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactoryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactoryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/hipchat/HipChatActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/ExecutableJiraActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactoryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactoryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/jira/JiraActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/logging/LoggingActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/pagerduty/PagerDutyActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/ExecutableSlackActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionFactoryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/slack/SlackActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/AckThrottlerTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/AckThrottlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/AckThrottlerTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/AckThrottlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/ActionThrottleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/ActionThrottleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/ActionThrottleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/ActionThrottleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/PeriodThrottlerTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/PeriodThrottlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/PeriodThrottlerTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/PeriodThrottlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/WatchThrottlerTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/WatchThrottlerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/WatchThrottlerTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/throttler/WatchThrottlerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookHttpsIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookHttpsIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookHttpsIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookHttpsIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpClientTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpClientTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpClientTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpClientTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpConnectionTimeoutTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpConnectionTimeoutTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpConnectionTimeoutTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpConnectionTimeoutTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpReadTimeoutTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpReadTimeoutTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpReadTimeoutTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpReadTimeoutTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplateTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplateTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTemplateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/HttpResponseTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStreamTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStreamTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStreamTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/http/SizeLimitInputStreamTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/stats/CountersTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/stats/CountersTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/stats/CountersTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/stats/CountersTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/AlwaysConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/AlwaysConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/AlwaysConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/AlwaysConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java index 9779a374669..8368bdba598 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionSearchTests.java @@ -25,6 +25,7 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.collection.IsMapContaining.hasEntry; public class ArrayCompareConditionSearchTests extends AbstractWatcherIntegrationTestCase { + public void testExecuteWithAggs() throws Exception { String index = "test-index"; String type = "test-type"; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ArrayCompareConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionSearchTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/CompareConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/NeverConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/NeverConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/NeverConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/NeverConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/crypto/CryptoServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/crypto/CryptoServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/crypto/CryptoServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/crypto/CryptoServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java index b0608a8caba..0434db57655 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java @@ -125,9 +125,9 @@ public class TriggeredWatchStoreTests extends ESTestCase { .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1) .build(); - metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings) + metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStoreField.INDEX_NAME).settings(settings) .numberOfShards(numShards).numberOfReplicas(1)); - final Index index = metaDataBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex(); + final Index index = metaDataBuilder.get(TriggeredWatchStoreField.INDEX_NAME).getIndex(); IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index); for (int i = 0; i < numShards; i++) { final ShardRoutingState state; @@ -160,8 +160,8 @@ public class TriggeredWatchStoreTests extends ESTestCase { RoutingTable.Builder routingTableBuilder = RoutingTable.builder(); MetaData.Builder metaDataBuilder = MetaData.builder(); - metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(indexSettings)); - final Index index = metaDataBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex(); + metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStoreField.INDEX_NAME).settings(indexSettings)); + final Index index = metaDataBuilder.get(TriggeredWatchStoreField.INDEX_NAME).getIndex(); IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index); ShardId shardId = new ShardId(index, 0); indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(shardId) @@ -186,7 +186,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { when(searchResponse1.getSuccessfulShards()).thenReturn(1); when(searchResponse1.getTotalShards()).thenReturn(1); BytesArray source = new BytesArray("{}"); - SearchHit hit = new SearchHit(0, "first_foo", new Text(TriggeredWatchStore.DOC_TYPE), null); + SearchHit hit = new SearchHit(0, "first_foo", new Text(TriggeredWatchStoreField.DOC_TYPE), null); hit.version(1L); hit.shard(new SearchShardTarget("_node_id", index, 0, null)); hit.sourceRef(source); @@ -198,7 +198,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { searchFuture.onResponse(searchResponse1); // First return a scroll response with a single hit and then with no hits - hit = new SearchHit(0, "second_foo", new Text(TriggeredWatchStore.DOC_TYPE), null); + hit = new SearchHit(0, "second_foo", new Text(TriggeredWatchStoreField.DOC_TYPE), null); hit.version(1L); hit.shard(new SearchShardTarget("_node_id", index, 0, null)); hit.sourceRef(source); @@ -264,7 +264,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { RoutingTable.Builder routingTableBuilder = RoutingTable.builder(); MetaData.Builder metaDataBuilder = MetaData.builder(); metaDataBuilder.put(IndexMetaData.builder("triggered-watches-alias").settings(indexSettings) - .putAlias(new AliasMetaData.Builder(TriggeredWatchStore.INDEX_NAME).build())); + .putAlias(new AliasMetaData.Builder(TriggeredWatchStoreField.INDEX_NAME).build())); final Index index = metaDataBuilder.get("triggered-watches-alias").getIndex(); IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index); ShardId shardId = new ShardId(index, 0); @@ -288,9 +288,9 @@ public class TriggeredWatchStoreTests extends ESTestCase { MetaData.Builder metaDataBuilder = MetaData.builder(); RoutingTable.Builder routingTableBuilder = RoutingTable.builder(); metaDataBuilder.put(IndexMetaData.builder("triggered-watches-alias").settings(indexSettings) - .putAlias(new AliasMetaData.Builder(TriggeredWatchStore.INDEX_NAME).build())); + .putAlias(new AliasMetaData.Builder(TriggeredWatchStoreField.INDEX_NAME).build())); metaDataBuilder.put(IndexMetaData.builder("whatever").settings(indexSettings) - .putAlias(new AliasMetaData.Builder(TriggeredWatchStore.INDEX_NAME).build())); + .putAlias(new AliasMetaData.Builder(TriggeredWatchStoreField.INDEX_NAME).build())); final Index index = metaDataBuilder.get("triggered-watches-alias").getIndex(); IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index); @@ -316,7 +316,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { ClusterState.Builder csBuilder = new ClusterState.Builder(new ClusterName("_name")); MetaData.Builder metaDataBuilder = MetaData.builder(); - metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME) + metaDataBuilder.put(IndexMetaData.builder(TriggeredWatchStoreField.INDEX_NAME) .settings(indexSettings) .state(IndexMetaData.State.CLOSE)); csBuilder.metaData(metaDataBuilder); @@ -336,7 +336,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { public void testIndexNotFoundButInMetaData() throws Exception { ClusterState.Builder csBuilder = new ClusterState.Builder(new ClusterName("_name")); MetaData.Builder metaDataBuilder = MetaData.builder() - .put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(indexSettings)); + .put(IndexMetaData.builder(TriggeredWatchStoreField.INDEX_NAME).settings(indexSettings)); csBuilder.metaData(metaDataBuilder); ClusterState cs = csBuilder.build(); @@ -348,7 +348,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { when(adminClient.indices()).thenReturn(indicesAdminClient); PlainActionFuture future = PlainActionFuture.newFuture(); when(indicesAdminClient.refresh(any())).thenReturn(future); - future.onFailure(new IndexNotFoundException(TriggeredWatchStore.INDEX_NAME)); + future.onFailure(new IndexNotFoundException(TriggeredWatchStoreField.INDEX_NAME)); Collection triggeredWatches = triggeredWatchStore.findTriggeredWatches(Collections.singletonList(watch), cs); assertThat(triggeredWatches, hasSize(0)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryActionConditionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java index ff37198759d..3a54f650365 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryStoreTests.java @@ -39,8 +39,8 @@ import org.junit.Before; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; -import static org.elasticsearch.xpack.watcher.history.HistoryStore.getHistoryIndexNameForTime; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.INDEX_TEMPLATE_VERSION; +import static org.elasticsearch.xpack.watcher.history.HistoryStoreField.getHistoryIndexNameForTime; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java index 10975e26241..cfc90812c7a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateEmailMappingsTests.java @@ -87,7 +87,7 @@ public class HistoryTemplateEmailMappingsTests extends AbstractWatcherIntegratio // the action should fail as no email server is available assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1); - SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() + SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() .aggregation(terms("from").field("result.actions.email.message.from")) .aggregation(terms("to").field("result.actions.email.message.to")) .aggregation(terms("cc").field("result.actions.email.message.cc")) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java index d6f324d29f1..a8394ebe44d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateHttpMappingsTests.java @@ -86,7 +86,7 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration // the action should fail as no email server is available assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1); - SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() + SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() .aggregation(terms("input_result_path").field("result.input.http.request.path")) .aggregation(terms("input_result_host").field("result.input.http.request.host")) .aggregation(terms("webhook_path").field("result.actions.webhook.request.path"))) @@ -116,7 +116,7 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration public void testExceptionMapping() { // delete all history indices to ensure that we only need to check a single index - assertAcked(client().admin().indices().prepareDelete(HistoryStore.INDEX_PREFIX + "*")); + assertAcked(client().admin().indices().prepareDelete(HistoryStoreField.INDEX_PREFIX + "*")); String id = randomAlphaOfLength(10); // switch between delaying the input or the action http request @@ -145,15 +145,15 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration watcherClient().prepareExecuteWatch(id).setRecordExecution(true).get(); // ensure watcher history index has been written with this id - flushAndRefresh(HistoryStore.INDEX_PREFIX + "*"); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") + flushAndRefresh(HistoryStoreField.INDEX_PREFIX + "*"); + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX + "*") .setQuery(QueryBuilders.termQuery("watch_id", id)) .get(); assertHitCount(searchResponse, 1L); // ensure that enabled is set to false List indexed = new ArrayList<>(); - GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings(HistoryStore.INDEX_PREFIX + "*").get(); + GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings(HistoryStoreField.INDEX_PREFIX + "*").get(); Iterator> iterator = mappingsResponse.getMappings().valuesIt(); while (iterator.hasNext()) { ImmutableOpenMap mapping = iterator.next(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java index b99d29fc1eb..99bd06ef7ec 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java @@ -46,7 +46,7 @@ public class HistoryTemplateIndexActionMappingsTests extends AbstractWatcherInte flush(); refresh(); - SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() + SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() .aggregation(terms("index_action_indices").field("result.actions.index.response.index")) .aggregation(terms("index_action_types").field("result.actions.index.response.type"))) .get(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java index a78976011e4..90710f64b40 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateSearchInputMappingsTests.java @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.notNullValue; * not analyzed so they can be used in aggregations */ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherIntegrationTestCase { - + public void testHttpFields() throws Exception { String index = "the-index"; String type = "the-type"; @@ -59,7 +59,7 @@ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherInte // the action should fail as no email server is available assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1); - SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() + SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() .aggregation(terms("input_search_type").field("result.input.search.request.search_type")) .aggregation(terms("input_indices").field("result.input.search.request.indices")) .aggregation(terms("input_types").field("result.input.search.request.types")) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java index 153d4bd829e..a62cc89cc7f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTimeMappingsTests.java @@ -48,7 +48,7 @@ public class HistoryTemplateTimeMappingsTests extends AbstractWatcherIntegration assertThat(mappingsResponse, notNullValue()); assertThat(mappingsResponse.getMappings().isEmpty(), is(false)); for (ObjectObjectCursor> metadatas : mappingsResponse.getMappings()) { - if (!metadatas.key.startsWith(HistoryStore.INDEX_PREFIX)) { + if (!metadatas.key.startsWith(HistoryStoreField.INDEX_PREFIX)) { continue; } MappingMetaData metadata = metadatas.value.get("doc"); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTransformMappingsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTransformMappingsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTransformMappingsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateTransformMappingsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/InputRegistryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java index 79d2424f8c2..3366f65147f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainInputTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.common.http.auth.basic.BasicAuth; import org.elasticsearch.xpack.watcher.condition.ScriptCondition; @@ -133,7 +133,7 @@ public class ChainInputTests extends ESTestCase { HttpInput.Builder httpInputBuilder = httpInput(HttpRequestTemplate.builder("theHost", 1234) .path("/index/_search") .body(jsonBuilder().startObject().field("size", 1).endObject().string()) - .auth(new BasicAuth("test", SecuritySettingsSource.TEST_PASSWORD.toCharArray()))); + .auth(new BasicAuth("test", SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); ChainInput.Builder chainedInputBuilder = chainInput() .add("foo", httpInputBuilder) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ChainIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/chain/ExecutableChainInputTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/http/HttpInputTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/simple/SimpleInputTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/AccountsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachmentTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachmentTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachmentTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/DataAttachmentTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java similarity index 99% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java index 43a02037401..63d3f897a30 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailSecretsIntegrationTests.java @@ -43,7 +43,6 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; public class EmailSecretsIntegrationTests extends AbstractWatcherIntegrationTestCase { - private EmailServer server; private Boolean encryptSensitiveData; private byte[] encryptionKey; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizerTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizerTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/HtmlSanitizerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/ProfileTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/ProfileTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/ProfileTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/ProfileTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/DataAttachmentParserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/EmailAttachmentParsersTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/HttpEmailAttachementParserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParserTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/support/EmailServer.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/support/EmailServer.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/email/support/EmailServer.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/email/support/EmailServer.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatAccountsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessageTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessageTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessageTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatMessageTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/HipChatServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccountTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccountTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccountTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/IntegrationAccountTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccountTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccountTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccountTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/UserAccountTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1AccountTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1AccountTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1AccountTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/hipchat/V1AccountTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraAccountTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssueTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssueTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssueTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/jira/JiraIssueTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaultsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaultsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaultsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/IncidentEventDefaultsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccountsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccountsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccountsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/pagerduty/PagerDutyAccountsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaultsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaultsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaultsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageDefaultsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/FilterXContentTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/VariablesTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/VariablesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/VariablesTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/VariablesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherDateTimeUtilsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherDateTimeUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherDateTimeUtilsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherDateTimeUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java similarity index 91% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index 486a8b48d5e..d11446d9192 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -84,8 +84,8 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { verify(client.admin().indices(), times(3)).putTemplate(argumentCaptor.capture(), anyObject()); // now delete one template from the cluster state and lets retry - ClusterChangedEvent newEvent = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME, - WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME), nodes); + ClusterChangedEvent newEvent = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME, + WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME), nodes); registry.clusterChanged(newEvent); verify(client.admin().indices(), times(4)).putTemplate(argumentCaptor.capture(), anyObject()); } @@ -94,9 +94,9 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(".watch-history")), is(false)); assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(".watch-history", ".triggered_watches", ".watches")), is(false)); - assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME, + assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME, ".triggered_watches", ".watches")), is(true)); - assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME, + assertThat(WatcherIndexTemplateRegistry.validate(createClusterState(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME, ".triggered_watches", ".watches", "whatever", "else")), is(true)); } @@ -107,13 +107,13 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { DiscoveryNode masterNode = new DiscoveryNode("master", ESTestCase.buildNewFakeTransportAddress(), Version.V_6_0_0); DiscoveryNodes nodes = DiscoveryNodes.builder().localNodeId("node").masterNodeId("master").add(localNode).add(masterNode).build(); - ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME, - WatcherIndexTemplateRegistry.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); + ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, + WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); registry.clusterChanged(event); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(PutIndexTemplateRequest.class); verify(client.admin().indices(), times(1)).putTemplate(argumentCaptor.capture(), anyObject()); - assertThat(argumentCaptor.getValue().name(), is(WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME)); + assertThat(argumentCaptor.getValue().name(), is(WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME)); } public void testThatTemplatesAreNotAppliedOnSameVersionNodes() { @@ -121,8 +121,8 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { DiscoveryNode masterNode = new DiscoveryNode("master", ESTestCase.buildNewFakeTransportAddress(), Version.CURRENT); DiscoveryNodes nodes = DiscoveryNodes.builder().localNodeId("node").masterNodeId("master").add(localNode).add(masterNode).build(); - ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME, - WatcherIndexTemplateRegistry.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); + ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, + WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); registry.clusterChanged(event); verifyZeroInteractions(client); @@ -132,8 +132,8 @@ public class WatcherIndexTemplateRegistryTests extends ESTestCase { DiscoveryNode localNode = new DiscoveryNode("node", ESTestCase.buildNewFakeTransportAddress(), Version.CURRENT); DiscoveryNodes nodes = DiscoveryNodes.builder().localNodeId("node").add(localNode).build(); - ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME, - WatcherIndexTemplateRegistry.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); + ClusterChangedEvent event = createClusterChangedEvent(Arrays.asList(WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, + WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME, ".watch-history-6"), nodes); registry.clusterChanged(event); verifyZeroInteractions(client); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/MapPathTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/MapPathTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/MapPathTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/MapPathTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/XContentSourceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/XContentSourceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/XContentSourceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/xcontent/XContentSourceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 53b8ac4c5d3..d00efd82826 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -39,23 +39,23 @@ import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.store.MockFSIndexStore; import org.elasticsearch.test.transport.MockTransportService; -import org.elasticsearch.xpack.TimeWarpedXPackPlugin; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; import org.elasticsearch.xpack.XPackClient; -import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; -import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.ml.MachineLearningField; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.template.TemplateUtils; import org.elasticsearch.xpack.watcher.WatcherState; import org.elasticsearch.xpack.watcher.client.WatcherClient; import org.elasticsearch.xpack.watcher.execution.ExecutionState; -import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.notification.email.Authentication; import org.elasticsearch.xpack.watcher.notification.email.Email; import org.elasticsearch.xpack.watcher.notification.email.EmailService; import org.elasticsearch.xpack.watcher.notification.email.Profile; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource; import org.elasticsearch.xpack.watcher.transport.actions.stats.WatcherStatsResponse; import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock; @@ -86,9 +86,9 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.HISTORY_TEMPLATE_NAME; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.TRIGGERED_TEMPLATE_NAME; -import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry.WATCHES_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.HISTORY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME; +import static org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField.WATCHES_TEMPLATE_NAME; import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.everyItem; @@ -115,10 +115,8 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase // watcher settings that should work despite randomization .put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100)) .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) - // Disable native ML autodetect_process as the c++ controller won't be available - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) - //.put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4) - //.put(NetworkModule.HTTP_TYPE_KEY, Security.NAME4) + //.put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4) + //.put(NetworkModule.HTTP_TYPE_KEY, SecurityField.NAME4) .build(); } @@ -126,15 +124,15 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected Settings transportClientSettings() { return Settings.builder() .put("client.transport.sniff", false) - .put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4) - .put(NetworkModule.HTTP_TYPE_KEY, Security.NAME4) + .put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4) + .put(NetworkModule.HTTP_TYPE_KEY, SecurityField.NAME4) .build(); } @Override protected Set excludeTemplates() { Set excludes = new HashSet<>(); - excludes.addAll(Arrays.asList(WatcherIndexTemplateRegistry.TEMPLATE_NAMES)); + excludes.addAll(Arrays.asList(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES)); return Collections.unmodifiableSet(excludes); } @@ -162,11 +160,13 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected List> pluginTypes() { List> types = new ArrayList<>(); + if (timeWarped()) { - types.add(TimeWarpedXPackPlugin.class); + types.add(TimeWarpedWatcher.class); } else { - types.add(XPackPlugin.class); + types.add(LocalStateWatcher.class); } + types.add(CommonAnalysisPlugin.class); return types; } @@ -265,7 +265,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase CreateIndexResponse response = client().admin().indices().prepareCreate(newIndex) .setCause("Index to test aliases with .triggered-watches index") - .addAlias(new Alias(TriggeredWatchStore.INDEX_NAME)) + .addAlias(new Alias(TriggeredWatchStoreField.INDEX_NAME)) .setSettings((Map) parserMap.get("settings")) .addMapping("doc", (Map) allMappings.get("doc")) .get(); @@ -273,11 +273,11 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase ensureGreen(newIndex); } } else { - assertAcked(client().admin().indices().prepareCreate(TriggeredWatchStore.INDEX_NAME)); - ensureGreen(TriggeredWatchStore.INDEX_NAME); + assertAcked(client().admin().indices().prepareCreate(TriggeredWatchStoreField.INDEX_NAME)); + ensureGreen(TriggeredWatchStoreField.INDEX_NAME); } - String historyIndex = HistoryStore.getHistoryIndexNameForTime(DateTime.now(DateTimeZone.UTC)); + String historyIndex = HistoryStoreField.getHistoryIndexNameForTime(DateTime.now(DateTimeZone.UTC)); assertAcked(client().admin().indices().prepareCreate(historyIndex)); ensureGreen(historyIndex); @@ -301,7 +301,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected long watchRecordCount(QueryBuilder query) { refresh(); - return docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", + return docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*", HistoryStore.DOC_TYPE, SearchSourceBuilder.searchSource().query(query)); } @@ -314,7 +314,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } protected SearchResponse searchHistory(SearchSourceBuilder builder) { - return client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(builder).get(); + return client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(builder).get(); } protected T getInstanceFromMaster(Class type) { @@ -325,10 +325,6 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase return getInstanceFromMaster(WatchParser.class); } - public AbstractWatcherIntegrationTestCase() { - super(); - } - protected WatcherClient watcherClient() { return randomBoolean() ? new XPackClient(client()).watcher() : new WatcherClient(client()); } @@ -355,7 +351,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase assertBusy(() -> { ClusterState state = client().admin().cluster().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, - IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*"); + IndicesOptions.lenientExpandOpen(), HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index); @@ -364,7 +360,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", ExecutionState.EXECUTED.id()))) @@ -390,14 +386,14 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected SearchResponse searchWatchRecords(Consumer requestBuilderCallback) { SearchRequestBuilder builder = - client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").setTypes(HistoryStore.DOC_TYPE); + client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setTypes(HistoryStore.DOC_TYPE); requestBuilderCallback.accept(builder); return builder.get(); } protected long findNumberOfPerformedActions(String watchName) { refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", ExecutionState.EXECUTED.id()))) .get(); @@ -413,7 +409,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase // so we to check first is this index is created and shards are started ClusterState state = client().admin().cluster().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, - IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*"); + IndicesOptions.lenientExpandOpen(), HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index); @@ -421,7 +417,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase assertThat(routingTable.allPrimaryShardsActive(), is(true)); } refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", ExecutionState.EXECUTION_NOT_NEEDED.id()))) @@ -445,7 +441,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase assertBusy(() -> { ClusterState state = client().admin().cluster().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), - HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*"); + HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*"); assertThat(watchHistoryIndices, not(emptyArray())); for (String index : watchHistoryIndices) { IndexRoutingTable routingTable = state.getRoutingTable().index(index); @@ -454,7 +450,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", recordState.id()))) .get(); diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/LocalStateWatcher.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/LocalStateWatcher.java new file mode 100644 index 00000000000..5489d4098b9 --- /dev/null +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/LocalStateWatcher.java @@ -0,0 +1,34 @@ +/* + * 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.test; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; + +import java.nio.file.Path; + +public class LocalStateWatcher extends LocalStateCompositeXPackPlugin { + public LocalStateWatcher(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + LocalStateWatcher thisVar = this; + + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + + }); + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/MockTextTemplateEngine.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/MockTextTemplateEngine.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/MockTextTemplateEngine.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/MockTextTemplateEngine.java diff --git a/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java new file mode 100644 index 00000000000..d0e939cdcdf --- /dev/null +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/TimeWarpedWatcher.java @@ -0,0 +1,108 @@ +/* + * 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.test; + +import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.util.Providers; +import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.common.logging.ServerLoggers; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; +import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.ssl.SSLService; +import org.elasticsearch.xpack.watcher.Watcher; +import org.elasticsearch.xpack.watcher.WatcherFeatureSet; +import org.elasticsearch.xpack.watcher.WatcherService; +import org.elasticsearch.xpack.watcher.execution.ExecutionService; +import org.elasticsearch.xpack.watcher.execution.SyncTriggerEventConsumer; +import org.elasticsearch.xpack.watcher.execution.WatchExecutor; +import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock; +import org.elasticsearch.xpack.watcher.trigger.TriggerEngine; +import org.elasticsearch.xpack.watcher.trigger.TriggerEvent; +import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleRegistry; +import org.elasticsearch.xpack.watcher.watch.clock.ClockMock; + +import java.nio.file.Path; +import java.time.Clock; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.function.Consumer; +import java.util.stream.Stream; + +public class TimeWarpedWatcher extends LocalStateCompositeXPackPlugin { + + // use a single clock across all nodes using this plugin, this lets keep it static + private static final ClockMock clock = new ClockMock(); + + public TimeWarpedWatcher(final Settings settings, final Path configPath) throws Exception { + super(settings, configPath); + Logger logger = ServerLoggers.getLogger(TimeWarpedWatcher.class, settings); + logger.info("using time warped watchers plugin"); + + TimeWarpedWatcher thisVar = this; + + plugins.add(new Watcher(settings) { + @Override + protected SSLService getSslService() { + return thisVar.getSslService(); + } + + @Override + protected XPackLicenseState getLicenseState() { + return thisVar.getLicenseState(); + } + + @Override + protected Clock getClock() { + return clock; + } + + @Override + protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry){ + return new ScheduleTriggerEngineMock(settings, scheduleRegistry, clock); + } + + @Override + protected WatchExecutor getWatchExecutor(ThreadPool threadPool) { + return new SameThreadExecutor(); + } + + @Override + protected Consumer> getTriggerEngineListener(ExecutionService executionService){ + return new SyncTriggerEventConsumer(settings, executionService); + } + }); + } + + public static class SameThreadExecutor implements WatchExecutor { + + @Override + public Stream tasks() { + return Stream.empty(); + } + + @Override + public BlockingQueue queue() { + return new ArrayBlockingQueue<>(1); + } + + @Override + public long largestPoolSize() { + return 1; + } + + @Override + public void execute(Runnable runnable) { + runnable.run(); + } + } +} diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatchExecutionContextMockBuilder.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatchExecutionContextMockBuilder.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatchExecutionContextMockBuilder.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatchExecutionContextMockBuilder.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/ScheduleEngineTriggerBenchmark.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java similarity index 90% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java index 27b24e14ef4..18ad645a52a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java @@ -67,7 +67,7 @@ public class WatcherExecutorServiceBenchmark { protected static void start() throws Exception { Node node = new MockNode(Settings.builder().put(SETTINGS).put("node.data", false).build(), - Arrays.asList(XPackBenchmarkPlugin.class)); + Arrays.asList(BenchmarkWatcher.class)); client = node.client(); client.admin().cluster().prepareHealth("*").setWaitForGreenStatus().get(); Thread.sleep(5000); @@ -213,27 +213,16 @@ public class WatcherExecutorServiceBenchmark { } - public static final class XPackBenchmarkPlugin extends XPackPlugin { + public static class BenchmarkWatcher extends Watcher { - public XPackBenchmarkPlugin( - Settings settings, - Path configPath) throws IOException, DestroyFailedException, OperatorCreationException, GeneralSecurityException { - super(settings, configPath); - watcher = new BenchmarkWatcher(settings); + public BenchmarkWatcher(Settings settings) { + super(settings); + ServerLoggers.getLogger(BenchmarkWatcher.class, settings).info("using watcher benchmark plugin"); } - public static class BenchmarkWatcher extends Watcher { - - public BenchmarkWatcher(Settings settings) { - super(settings); - ServerLoggers.getLogger(XPackBenchmarkPlugin.class, settings).info("using watcher benchmark plugin"); - } - - @Override - protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { - return new ScheduleTriggerEngineMock(settings, scheduleRegistry, clock); - } + @Override + protected TriggerEngine getTriggerEngine(Clock clock, ScheduleRegistry scheduleRegistry) { + return new ScheduleTriggerEngineMock(settings, scheduleRegistry, clock); } } - } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java index 1bfd6a3d550..46da0052a05 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherScheduleEngineBenchmark.java @@ -34,7 +34,8 @@ import org.elasticsearch.xpack.watcher.actions.logging.LoggingLevel; import org.elasticsearch.xpack.watcher.client.WatchSourceBuilder; import org.elasticsearch.xpack.watcher.client.WatcherClient; import org.elasticsearch.xpack.watcher.condition.ScriptCondition; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; +import org.elasticsearch.xpack.watcher.test.LocalStateWatcher; import org.elasticsearch.xpack.watcher.watch.Watch; import java.io.IOException; @@ -139,10 +140,10 @@ public class WatcherScheduleEngineBenchmark { .put("xpack.watcher.trigger.schedule.engine", engine) .put("node.data", false) .build(); - try (Node node = new MockNode(settings, Arrays.asList(XPackPlugin.class, XPackPlugin.class))) { + try (Node node = new MockNode(settings, Arrays.asList(LocalStateWatcher.class))) { try (Client client = node.client()) { client.admin().cluster().prepareHealth().setWaitForNodes("2").get(); - client.admin().indices().prepareDelete(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get(); + client.admin().indices().prepareDelete(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").get(); client.admin().cluster().prepareHealth(Watch.INDEX, "test").setWaitForYellowStatus().get(); Clock clock = node.injector().getInstance(Clock.class); @@ -188,13 +189,13 @@ public class WatcherScheduleEngineBenchmark { } } } - client.admin().indices().prepareRefresh(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").get(); + client.admin().indices().prepareRefresh(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").get(); Script script = new Script( ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "doc['trigger_event.schedule.triggered_time'].value - doc['trigger_event.schedule.scheduled_time'].value", emptyMap()); - SearchResponse searchResponse = client.prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client.prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setQuery(QueryBuilders.rangeQuery("trigger_event.schedule.scheduled_time").gte(startTime).lte(endTime)) .addAggregation(terms("state").field("state")) .addAggregation(histogram("delay") diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java index 17132b05392..47e0c029cb3 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/BootStrapTests.java @@ -18,9 +18,10 @@ import org.elasticsearch.xpack.watcher.condition.CompareCondition; import org.elasticsearch.xpack.watcher.condition.ExecutableCondition; import org.elasticsearch.xpack.watcher.execution.ExecutionState; import org.elasticsearch.xpack.watcher.execution.TriggeredWatch; -import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore; +import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStoreField; import org.elasticsearch.xpack.watcher.execution.Wid; import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.history.WatchRecord; import org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateRequest; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; @@ -66,7 +67,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { @Before public void deleteAllWatchHistoryIndices() { - assertAcked(client().admin().indices().prepareDelete(HistoryStore.INDEX_PREFIX + "*")); + assertAcked(client().admin().indices().prepareDelete(HistoryStoreField.INDEX_PREFIX + "*")); } public void testLoadMalformedWatchRecord() throws Exception { @@ -87,7 +88,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { Wid wid = new Wid("_id", now); ScheduleTriggerEvent event = new ScheduleTriggerEvent("_id", now, now); ExecutableCondition condition = InternalAlwaysCondition.INSTANCE; - String index = HistoryStore.getHistoryIndexNameForTime(now); + String index = HistoryStoreField.getHistoryIndexNameForTime(now); client().prepareIndex(index, HistoryStore.DOC_TYPE, wid.value()) .setSource(jsonBuilder().startObject() .startObject(WatchRecord.TRIGGER_EVENT.getPreferredName()) @@ -216,8 +217,8 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { Wid wid = new Wid(watchId, now); TriggeredWatch triggeredWatch = new TriggeredWatch(wid, event); bulkRequestBuilder.add( - client().prepareIndex(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value()) - .setSource(jsonBuilder().value(triggeredWatch)) + client().prepareIndex(TriggeredWatchStoreField.INDEX_NAME, + TriggeredWatchStoreField.DOC_TYPE, triggeredWatch.id().value()).setSource(jsonBuilder().value(triggeredWatch)) .request()); } bulkRequestBuilder.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); @@ -259,7 +260,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { Wid wid = new Wid(watchId, now); TriggeredWatch triggeredWatch = new TriggeredWatch(wid, event); bulkRequestBuilder.add(client() - .prepareIndex(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value()) + .prepareIndex(TriggeredWatchStoreField.INDEX_NAME, TriggeredWatchStoreField.DOC_TYPE, triggeredWatch.id().value()) .setSource(jsonBuilder().value(triggeredWatch)) .setWaitForActiveShards(ActiveShardCount.ALL) ); @@ -286,7 +287,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { long successfulWatchExecutions = searchResponse.getHits().getTotalHits(); // the watch history should contain entries for each triggered watch, which a few have been marked as not executed - SearchResponse historySearchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setSize(10000).get(); + SearchResponse historySearchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX + "*").setSize(10000).get(); assertHitCount(historySearchResponse, expectedWatchHistoryCount); long notExecutedCount = Arrays.stream(historySearchResponse.getHits().getHits()) .filter(hit -> hit.getSourceAsMap().get("state").equals(ExecutionState.NOT_EXECUTED_ALREADY_QUEUED.id())) @@ -318,7 +319,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { assertAcked(client().admin().indices().prepareCreate(Watch.INDEX)); } DateTime triggeredTime = new DateTime(2015, 11, 5, 0, 0, 0, 0, DateTimeZone.UTC); - final String watchRecordIndex = HistoryStore.getHistoryIndexNameForTime(triggeredTime); + final String watchRecordIndex = HistoryStoreField.getHistoryIndexNameForTime(triggeredTime); logger.info("Stopping watcher"); ensureWatcherStarted(); @@ -332,8 +333,8 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase { Wid wid = new Wid(watchId, triggeredTime); TriggeredWatch triggeredWatch = new TriggeredWatch(wid, event); bulkRequestBuilder.add( - client().prepareIndex(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value()) - .setSource(jsonBuilder().value(triggeredWatch)) + client().prepareIndex(TriggeredWatchStoreField.INDEX_NAME, + TriggeredWatchStoreField.DOC_TYPE, triggeredWatch.id().value()).setSource(jsonBuilder().value(triggeredWatch)) ); String id = internalCluster().getInstance(ClusterService.class).localNode().getId(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/ExecutionVarsIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/ExecutionVarsIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/ExecutionVarsIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/ExecutionVarsIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java similarity index 96% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java index 073966bc01b..36e6513347a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HipChatServiceTests.java @@ -20,11 +20,12 @@ import org.elasticsearch.xpack.watcher.WatcherState; import org.elasticsearch.xpack.watcher.actions.hipchat.HipChatAction; import org.elasticsearch.xpack.watcher.client.WatcherClient; import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.notification.hipchat.HipChatAccount; import org.elasticsearch.xpack.watcher.notification.hipchat.HipChatMessage; import org.elasticsearch.xpack.watcher.notification.hipchat.HipChatService; import org.elasticsearch.xpack.watcher.notification.hipchat.SentMessages; +import org.elasticsearch.xpack.watcher.test.LocalStateWatcher; import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchResponse; import java.util.Arrays; @@ -48,7 +49,7 @@ public class HipChatServiceTests extends XPackSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Arrays.asList(XPackPlugin.class, MockMustacheScriptEngine.TestPlugin.class); + return Arrays.asList(LocalStateWatcher.class, MockMustacheScriptEngine.TestPlugin.class); } @Override @@ -178,8 +179,8 @@ public class HipChatServiceTests extends XPackSingleNodeTestCase { watcherClient.prepareExecuteWatch(id).setRecordExecution(true).execute().actionGet(); - client().admin().indices().prepareRefresh(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*").execute().actionGet(); - SearchResponse response = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + client().admin().indices().prepareRefresh(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").execute().actionGet(); + SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setSource(searchSource().query(boolQuery() .must(termQuery("result.actions.id", "hipchat")) .must(termQuery("result.actions.type", "hipchat")) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HttpSecretsIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HttpSecretsIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HttpSecretsIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/HttpSecretsIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/PagerDutyServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/PagerDutyServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/PagerDutyServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/PagerDutyServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchInputTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SlackServiceTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SlackServiceTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SlackServiceTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SlackServiceTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java index 9b4664ddc97..ee3eefc1066 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchAckTests.java @@ -18,7 +18,7 @@ import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.xpack.watcher.actions.ActionStatus; import org.elasticsearch.xpack.watcher.condition.CompareCondition; import org.elasticsearch.xpack.watcher.execution.ExecutionState; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.history.WatchRecord; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import org.elasticsearch.xpack.watcher.transport.actions.ack.AckWatchRequestBuilder; @@ -120,7 +120,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase { assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION)); - long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null, + long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*", null, matchQuery(WatchRecord.STATE.getPreferredName(), ExecutionState.ACKNOWLEDGED.id())); assertThat(throttledCount, greaterThan(0L)); } @@ -188,7 +188,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase { assertThat(parsedWatch.status().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION)); - long throttledCount = docCount(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*", null, + long throttledCount = docCount(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*", null, matchQuery(WatchRecord.STATE.getPreferredName(), ExecutionState.ACKNOWLEDGED.id())); assertThat(throttledCount, greaterThan(0L)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java index 895f37f0f8d..a1c4694ad68 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/integration/WatchMetadataTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.xpack.watcher.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; import org.elasticsearch.xpack.watcher.condition.CompareCondition; import org.elasticsearch.xpack.watcher.execution.ActionExecutionMode; -import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import org.elasticsearch.xpack.watcher.transport.actions.execute.ExecuteWatchResponse; @@ -59,7 +59,7 @@ public class WatchMetadataTests extends AbstractWatcherIntegrationTestCase { timeWarp().trigger("_name"); refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX_WITH_TEMPLATE + "*") + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*") .setQuery(termQuery("metadata.foo", "bar")) .get(); assertThat(searchResponse.getHits().getTotalHits(), greaterThan(0L)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/chain/ChainTransformTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/WatchRequestValidationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/WatchRequestValidationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/WatchRequestValidationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/WatchRequestValidationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/activate/ActivateWatchTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java similarity index 95% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java index 0cac2733d5e..9bb3459623c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/delete/DeleteWatchTests.java @@ -12,6 +12,7 @@ import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.xpack.watcher.common.http.HttpRequestTemplate; import org.elasticsearch.xpack.watcher.history.HistoryStore; +import org.elasticsearch.xpack.watcher.history.HistoryStoreField; import org.elasticsearch.xpack.watcher.support.xcontent.ObjectPath; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; import org.elasticsearch.xpack.watcher.transport.actions.delete.DeleteWatchResponse; @@ -76,9 +77,9 @@ public class DeleteWatchTests extends AbstractWatcherIntegrationTestCase { // the watch history shows a successful execution, even though the watch was deleted // during execution - refresh(HistoryStore.INDEX_PREFIX + "*"); + refresh(HistoryStoreField.INDEX_PREFIX + "*"); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*").setQuery(matchAllQuery()).get(); + SearchResponse searchResponse = client().prepareSearch(HistoryStoreField.INDEX_PREFIX + "*").setQuery(matchAllQuery()).get(); assertHitCount(searchResponse, 1); Map source = searchResponse.getHits().getAt(0).getSourceAsMap(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchRequestTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchRequestTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchRequestTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchRequestTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/execute/ExecuteWatchTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/get/GetWatchTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/ScheduleTriggerEngineMock.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/CronScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailyScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailyScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailyScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/DailyScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlyScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlyScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlyScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/HourlyScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/IntervalScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlyScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlyScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlyScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/MonthlyScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleRegistryTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTestCase.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEventTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEventTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEventTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/ScheduleTriggerEventTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklyScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklyScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklyScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/WeeklyScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlyScheduleTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlyScheduleTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlyScheduleTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/YearlyScheduleTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/engine/TickerScheduleEngineTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalToolTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalToolTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalToolTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalToolTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java index 2dcef2c192a..9d5dfdc0856 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java +++ b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusIntegrationTests.java @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.notNullValue; public class WatchStatusIntegrationTests extends AbstractWatcherIntegrationTestCase { - public void testThatStatusGetsUpdated() throws Exception { + public void testThatStatusGetsUpdated() { WatcherClient watcherClient = watcherClient(); watcherClient.preparePutWatch("_name") .setSource(watchBuilder() diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchStatusTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockTests.java b/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockTests.java rename to plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/clock/ClockTests.java diff --git a/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks b/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/testnode.jks new file mode 100644 index 0000000000000000000000000000000000000000..4df11f34c3650ee80fe23d33e3fa33e4246740c4 GIT binary patch literal 6766 zcmcIo2|Sc*+n?RO%aS#+Z_mgU$-Xbyw}>%DMi|SGHD zlzmH)^_}6Ij?VA=zVm+H`+hUOndiCg`?;TcyZ-;{f8E=2+jAfg2txY7cdzVtOaR^o z=Z29&dtos?cqw0hoIBPF0|J2!t(@e+Ah?~hJa7~Qg2DkJ6bul-Q`t}m7y_XJ-MEQm z?me0K1fWAuiO1^4uF`?QG;k2WjAR7p5m0LwH4BBc&lw-wSs#Fxoen97ltn5a73AgR zWgSSS63LYR-Td1&M6kgASA*doC=tv6A`O8WLIi_Bxa_VFiDw+;5A933CIeN&h;YX{P zD-z)eYHYnf{>Vv8{Lt1_iUNa~rx)X4@w`%n5!39;&eXYeX=0_U@=yx6rgRa%jiu1^ z)QD~K`+7B3M0I5pY;#Fn>3Kca>zTXv)gzKF!k6!b7|XE@y}4=oJvk|@nu4;iD2Lil z|Aw}Yj0Co4drGi}MPoeDDkoI`w;MHB!G{iCMw}yfZ82d^_zgfJJcWTdj9SX(rQY@2 zh#+?@>2}O=6Q0y<6nKu5L|#j!60y+17HVGkye|B1qJ~?01x?= z9>xY^U5lu94rgDHAG+Fk>?@W^b*{lN7?31aGr@!aK_ZnG4vq5izy;vrV3DNlj$gQ|aj=Uz(^2?u4{IzkT4<;YDp}F5E1RdG0|6)=*TidaZc`T`8obR}**{lM4sKP*2 z-E%Yi^40nDr>UmPcHhlHaP}A1+9}w%vgj{Fy%tYUwWP4i{LYx(<~(?q@}aqq7{f~l zVu;9V%W8^uPISy9Ef54mg+k-8K^Qlz|1L~UiBSB62_h9BB9Z|jJai8xEJoxO2j2IX z!5oO+cbE6C>k6DhvH(m7YN}-6i`SMV-N2k|P&CdP$pdixQb>pKLIvQl=l~4LAMJr; z1(<)ShLMqsWCj?2DTScikh}ml8IDkv11L8s9b*kkD+4V{9SsXDeGP3XEsZ^J0!p%q zNCi20IYlx!<@cF@5>f$>+k1nQ&fXX-cgLXNW<}~#8s#QU?pyko@kx`WK!WQ34B@n5 z;pNuK_3D_WF<;Bo7h&>l0{FuF^0@|b#Wzxw&~faPhgcA`u`VxNa#S{rZ-1Tm(QKV= zHg#jTRzU5dW~cb)hE`Agaj^mceg1+JS>5XswS0QPjIaCp}u_c*LJdC_^ z@f`viUT|0lR9c>T?ieGB8K}%5m&JH_!Mi+tD?irZ;1T9z+wF;VDNDiel@&@#dweMP_KhXI#5y z*WFn+PgfDE*b;C=N#Men8xE|}!AeX1fdnSyt1qi8AEVS^s2<^Dx`Q+?Zb4=X8TKGd zgqo1J)c}w|P)Q)bFfdV(6#^6BWJ|H~EpLF#ieK8>aJ+KSG z*Z@`pC8;GGP637dyaVr&Fb@M5yaR(lA@FP<_$N!~eKu^@ zra@4-#Oi}FP#9Po*k?%XHz4~BI6#4bOVC3h6ae+lms9LxrJaJEjD~P7X0JjIF}W|d zk-4><`T!r9l>}iN09zC*ftpJ*%fQktvxwGRw>PC!MX^y3Abcf1!3QJE0E9_^Fp*98 zm`xaoB@B7Fp?sBPWMs5VRsYtvB}o;33{e-IXp z2_RSPzt_U~xMNQT`lIkzoR6fo7O6Y(KiTie*I!(pTtM=EH8jQ_k9EhQQFx36CWyqg z{#e&Q@?X9V$oNjtv^lHIuF{3Bn*4d><8m&QBF=-~|B>9x%3 zaMn1R8{}T_8}i$?Ej78&O~H@4SD>%CDYllawj3|Kx)*jz$m~h^X;*dG6Kwpwmo749 zSWrZ%hpJj6SoN+AxgK%JQ@@$?!tq^l?x6?6**Ytl&xXU9I8x6Aw-E5hCdS^2$-viy zDIZmu_)eRNkL<+CZVC+^MlT^&P7YGYIBwZ~EzbMe7JXacRh(5@=JNVecV?YZhohTs zp1Dm!v%AgXVpbX>1$QFRT5mt(54|Bttf9d(OwSNmcFxK=Le&B^Y^g$m zU#|*pW;al?x~7BR@<#{e+8mIdPO@-a3WPJkLua)PZd?~U(^j+6PC?^=F&%?ETCJYD z2UqlN)jzScTu3;kUXj3K9_c%`UemVlV`C~WL*T=Q<`;prjFBp*lYpKZ82&q&RkG`m zlP9jYupZ@jBXap67i;rzmgLiM60_V4JaQ&;?&0)QLwY~jHIYzI+Y5Dl&zz`w(~S+2 zB)qpiH%dn6Q**=Z*aK5_mYq$*IvUPv%f&&*-d!eOLl>{uX?4fB^Eh0yMnE(pUnf_| z3LA_P1BrLU5k?WZ;df$uJl{AdsaM-egmC_Yo*bhv$L1m!${uK*=#K|Wu`ue-bNuIe zlDC=50G^en`5^Gf{T|js=2qLq@!MJhk&&-Q#JOI_e~)Irp14Dx<< zHRqh8GdmX+Bj=6pf{`B4-`nv0#QJMOT6&v2n^>tVYI~Pc8lO(i%SsjdcIOzTez;ui zIxh5h2O3)5I(hEmPHo6&mk5wMA5k%)@A<=KyW}WsP%F1;iA20<34CQbb2y-pLX0j{ zgtdJ5otmfJ=O^-ft7q#)U#sefa~6qcl!RbCK)GMA+P>k8LJqu>Pp$E1m3xO-dtcY? z;*t{Qi}4|I`7SD*O{#vP5=H|MVH6}(F6^Na{EK*mld>&cB+ah=hap%X)|P*Ok@~M- zq$5S?U6Ag{#NRVCC<}!@4u_XQqxOkF`6IIONB$IndnRD|f9i)6()T!k0qZM;RFsuE z0!RT;NO`$`l!lKk(l=hDW$BCYkP(3#Y^y0EPAxgj=k46F9Z(-z#ftp)WYnR`wpF>u zt{u2wwCwrS2Z&i_>|vb0eQOj@>ZUBU$$IAaqS*4wlgDZn+Xf4ZE+s5Md_I2K+7e3R zOb@=LIkZ`iWea|g`0P5@Vp$A&l@O`?Tn-RYOOAK4<^(Zy)Nt2@f;29TiZRB~wTXZD z=-^$UB&PyT&AKx-ZuGdU@{n@y`V-UeVx94* z=3J*MxN^45uX|`DtOA6U{rMfRC&^;hG{JN*LAFEoC`&7TJ&X^Aq)aew{A9_3@#o(c zk4c%uu81SI0F#9vLVed2co=?Hg@0y@$nDPgB31BmXz`_USKO>)7z+fnfFRQTk+c~O z@Qz|#7}t~(39HC)Gg84W7q!PZg(5d|4DTTV!%0?pDp2D6=8j@}=1NN&Cx!}Dk0 ztvb1kcR3pSZ~G>1m0va}N`5a8@LcY+Z#vI{oX3M9=d_(Udylaeu@9K2=NIT`-R$ON&E2kmiyEJA^#Y)zCF2n6Q zr+P1sTV;|?&sC@G?D7(xT!%z{SejwxqRI860)dD+a24-((az32o-Bz=eAD*MH6*S8 zgDA-{oP1!j%N33uq|_Y_C6UAqNxf6=rVru}CNSx+1V)6-3?HN)DTC+9S~G`jC!`%a5Z{m!ap>bsstG#-l~VVs(wTFkGYQv9wB%%%=gJP#D6c+?6Ftt| ze@40J9LgRlS*;x@dIV=hU$gAr7;o=?#pzvv`RoaQptm+=HpzgeTT=yBbaoP=Cr15l zvKKqbhwm2LnA%EecgkJKs8_WH|rj{0UKf5-}`8hgo zJ<85EUDYCrzMC1N2{!n6o8I?~=9>Z4>jU@8Z>qY~ALbA%F!&r5^^F78xSo|nxg4uL zo)&p?ioZ-~GrDu2;=*x&U=j{&qDL_=%+wT$SLenIHd|)2l}|Mxl4op7^L5!f+m)XZp#nOue=RCKjJD^`xO?2#-2mBKbdp!NKt<_!{Q6!&wgroK11c%u?cqPhe24?+0)IEy0tT+ z-=1$5M3-aFmuyr(FQ~n9yWMaZl;8HS@wD{?mA;OiFmX?H0owfO>Z|<|58^J|R4SAW zIzL&>b>eO4H{hK+YL)>}A5@j5?j}1Sf$e{+7I9pbf^OWSR8lZToQdKCU*ePUMrV7o z9cLy=>JsJrHI>(fmCr1@IJmP>44E{68Z2)|POA48P`tc$9-14@LqH~!%zvm{;5>WY zxS~Es8*!t-Cgnwg8kLEe@iH>lEjZ{N_^GI?xkwFXYj$6j$wg-3WXtPYTC%32=Tlmr zeX?RrS#-u_z14nsBDD9#@$$Mz?VF5x5Br(jEk38N4LzIrdLW#lU8YwMMdQWc7(Ol6Y$mv_`c)Es-k%&m#G$So_zR*%)b@}7GqI=`c-<|YdH3Wc+F zY=35?{=rK0p5_#u$d`ix5c5czC>Tp=G;>;Id{3_rlTCuG?F zCYdoM(eW>-jGUbO{#1r+{ug`tr$nafpv}DG;f(R@wSWyv6A>Q|JfDpH+Zya=87Uz# z3oY0Zr9{`=mdA+@GsO|;H8U}+{EzCGpnv&{~xkRJkcKI8sJ_A;@j6xZ4D#;^F)Sa?a^{? z_Dx5NmIB)Y5t55Ptk5sGU5EJ{?wIM{pFJXZ;l24n!TOo@1dWH-z?#tYy!O)A%Tdx_ zv(8Pszbe&vz;5C`A9!tvO^+f-=>D*1l;jHzY)uO1jOO)-S?aS^28IWgw$|cX44S?= zmNE}L;5|}E>zzR(Q+X{O3E(nxCI{u=7DwIhevr>U*v~v&cS|cHU{zvDGPgTS_G9XS z!*h{n@OyW#n)$&z8=JEDI;fr>^Vr2!3;$Q1viIN7sSyHQx)eUlJWo8TLF~@CdC~Lf z*?33$p0Cndy7x=3zInE#=B-}7J}{~r5Vbg?lE<*J?)ga$amMqv4AoDUZiHyZXJl9v Vq?|Bcgbn%{&Z8wV(^P#|{soAkNG|{Y literal 0 HcmV?d00001 diff --git a/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks b/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/keystore/truststore-testnode-only.jks new file mode 100644 index 0000000000000000000000000000000000000000..d75109b2a68544661f293cb766db1cc8527ce5c0 GIT binary patch literal 943 zcmezO_TO6u1_mY|W(3o$xs}wZE9jvLiPqDD+6;ABR_*d6C)Q>6C)$TIjOLBIx4dtFZfaXJJ?q}FQY_W zKk~-*%xC(#s+vL0EFU?v&#gPYtDh;r{66#K0L@IDM>A(V)p(^Vu6*^%-urXjoXoW< zO zN%6-PO=hd33twKmyCFoUHAI&$@b-f9tCw$eDOQcC2rm7a%dY>gw{fADZj}7b_EVOX zFBa`jZc7h+YW?>6wL5YNeFkC%ALj71%S!!U=Q~qDqA?+D(wWM4txU{}42+AT3?d9T zfpI1)%)(^AU?2-(^0A1qh^iU zPRz;3FD_|ksRt&lb^%~gLk3L9p$|+%z|d!85dN|A)8z#-VuFq@4HvD|`S3F&`G`!? zU4^JM0UjIQ80&Q03VgrxSN5r1$8DLV+pB&pKDDZ?r$O)Y+`3n37go7$68BAeS33El zm^*u!>c+bo4LV08GPh5WeC;%~_6=8gh^Lq6$G<V@fxzJ$vOuUg7+ M{_9`nv^f^V05mFT4gdfE literal 0 HcmV?d00001 diff --git a/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks b/plugin/watcher/src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode-no-subjaltname.jks new file mode 100644 index 0000000000000000000000000000000000000000..ec482775bd055647acc6297c5368a74ad8388c70 GIT binary patch literal 6284 zcmdUz2T+q;y2lBG-a(oa14xzfCiLD_dau$+1f+y6O@WAjbV2Ee^xk_>dKHl-s1#|U zfK;Uj2pe$sTRvy^emi$|=FZJblJlJR8}hcjBLV{hqJyHYz!gmenGysoBHW{yR9s&?UhUq7)3Lp@7Z z$P)NU5n+IeoPX&P^HbHh2RUUP?lxb&Eh%$Leq?5E*y!3-EQxgsmWUG4nC<#><`6jO zS_yuLO%(AdblX~b*K7OQp)=H+_3f9E9!s`OobgZlN;2vE%SZ;%!&zfxo%gr#I97W3 zygnyuOVU``n@SYYJPlu>l9Bbar7UQSCmdv!z{kV_VSuuOT7jSz03W>{jFezZ00Uq= zYm$Je!I#F`8=t&k=0Cl%b}KN>>~l-n4#f!&6mxc+92^u11O=n;9g#Lxj&?|Q4;0lO zO}_IM9O-0b?~Ee&qgxO~^UwChF@hHc311i_d~uL)C^!I}bfIMEw7mENUEE`IdZG6i zgi$;Mj@yLse7@Yhb!+4Cgq`bG2dek+#ws)Hw-?{)HWR9qSSH!jwAZ7mC+t_`67O-D z2G23f=k2nSI;N@&hMyAKS|VHwnH8U{Ay|5-tHUQcn%`yK3&0&pXc+@JeCo#W(HQpd z=@*enjT?xaqMJ=e(eA&NWG{$Ua8a!%VCfDEq<;7$gveT0?MKIt0_Bo6qtGYy7oqGZErFcN_}T%!oXRD70ZN z=oNM3hO>pNDC9?n)yXXvWvRhs*u5eES%@K1mQhu|6x2n^!JBnP1>0i(bx zOEsT+?nb1Gc|O8vl`Pk_FSPShup&cZ9O$XCk)V;{D7D7nO-Ija zkw{oOQ%2LVtrkP<#PgV*5@M5qkh`O1ufq`*lM^%D^1RV+K%Em)xbQ@AoP}Dj%<#Hh z<1BLuD)gbUD)!eGYG09g$}`6lTRJym$iMKCh;N+qjXPK^NnVb=8jXF@xwFNO{C=oh zw9d0jm(qCZTy5LsvQNz|#|U?7EIdeL&#UpFZ90}BP;CijX|u%l1je%xHrEFlhdP%g zo#8vyMfY7qy}KFn)rdRVSD^|)op-Tl4cvPa?#ct zF%wcf8*Wt3!0FxnJ|SRlD2Dz=bH1R6fZ~9RBF?nAKc88qD5Z0YGWM5E!9NYscPIAaLSKIPlnzn}VuDEzo#k;vKadxP!)nK^mzig(?5i{@o5aT!ch(bqnQb;Z?;$CG9Jilz?2GG#1N z@EYE|%6pwJx7X%QYOe=r-vu(M6F>NWOw8$Hclom7gDr=6T?V)NCA6CL;(Y)+Ns+En4gbI*8YZP6)I zTaD^L>-fMmz+P`N+r^8g)S(T+6vNaqQPypijk%BOe{~^=9sZ^6X8-Wk%y9LvDe;dl zD)$(<*|%QwZu+1?;@P)+WnUTy(pKI`>gX9ViU*Z$ocfo36Ps4+j46n{CL%wTYr#G$>DA)J{K3^Dg3EhxhhvcS3b`y)M6^mE&9B5tn;MQ{%z419K9JnyUvtdh#q$1GS11}>dNgp|YxM=N&^dmDFzm79$nlmlQp>&K#GQo7g=(L<{$hz43#p+6wH zavJA?M-U2w3PZ(&L}2HFM-&|j{XP8eFZfsLC#@h8&UnBn*k}be$#P26J{$)a` zsDXRLpK7=EN@4Hi+LV*rMTE^l>EOk>y-k>mHNMplkvEZ8{<(#cBb0QDU(z ztI{yfY0K(sI!4KZdJfW+pX6)A-vS5Mh|~&=OB4QjVw$%N5sAr2T+P0IwYcenfA|?RJXn!r>ka;oVvNm?sPN@_rl@m)yDU zCMw$>WBy6{@2>bzNMoMd(Ya%I~|!2xHUOh zBc&SlTauhBkz3@?_S@%Hf=3xrzIiR5L@^(<`!qdI)!ai>ba&h~x7Aue3fk!(lC9f5 zDXbn{XC7BrsD{j3_uQU*h;&%Bk8qxT(>g|mS1_O}Po z91-cUy0rdyO?+1?@9Z}~b_;)6bKjMxt~r8BTSO)~3#os%OYQnBu_|rQH%D?^OhHGX zVw~WWmP0*5pDoYPUDJ15g3^p$-u=t?nI;Ug8n87|a|_2d?Ptj|vzIfTN0evIb`CGT z*WZ2lJo{}~fWh{ALpIj|CgumPaIKx!;R}XsGwn;Z1nqU*QQ1`By2vLdbz&pWH-E3T{6Z@2Xy8aYxP%CjgSip#ru3HPPcBM;OAlxvH5R4trd$ZGif+>(Sw z$7YYIQH(Tut(|-;BOmC$uj;@MH&sc#T~)}-+ECbSFbE?{*M+~o+g=*nDo)xY&Ht+N zIJf?&>u3en2qowKpebTi6PGnIn_F$A!EZuwDW{x7?J(oOJ0@Qx{2_Jbil{V{|UkQ}WAAg!$_PCd? z)R~EC>9plqztLW*ni|7cgeMJiV2FRrx#O@I)+&y1vCF#5O}0+5~slpxS47#qMse_c2R1rgB8rz`8i)AEUK zUmtr?Bq7qticTE-bIptrp#q)FfbmNu;LAqVM>n2fj6lDSMMf^A3YA z0Ulo+v}hWfjpXA>*NSh`fO9T|0Y9*4Nrt&MsVhmz3j z8jAIj^Db5}YPGlCZtfKYsp1N8GI^*qf8TgzieqUcym>ioHn`26#|v+2D{RCtS44M# z|I&xP61$9sP?<;63Ugdm&(d6WhD(A5rc-6)bt|GiF{tRN7_UY&-G&bBSm2I+bT_F9 zlWeV@g}> zrLA18?ssGUp+|vj4}UoO(7!vDlI48ibq+tl8EU`G12p|;(*S7sxAfy#|k#HqgI z`t5cCD*s`@WdR_+@TL0~1y|wR!uZWx5c;#ZAY}4iUF)xK?8rMfDJR1HI5HGul$jpl z#VKrYBOKNjv@3FVIMywzv|Xl3+o@BE&4zg|A_;~Qllf^!u-9nI4}NlG=<=J0!iFNf z>ux$~WDsXTa56P(XN~OUtOKWScDUS{Z$|a|mjng^4X#%44KfCioT=IsT8u4Zj0ok; z(E;rx=Sv9ax0{8LK81ap#)NiKGC44hrL0Zcp1m+J^A!~nNwUDl5TVj z(@Bukx4v?(r-a0vJ#D{z>+pG!tyx7lq42XdyAQoyMwo`m zC`t*xJO4jS2;vreM$et?jF@)(XhNHxikf%*5OijddOOk35zF)rOR5R|0<|jnZRU1$ z*K*p({K?D!c9-%f+431sWvF?f#2PDGTvc|cZtSCUBhY<^{?Ovfb@#r{bnW9$WxPne z0^q7;!jzmvc|M4TEQq& z7hSd~#xya_qb9Sg@N~YpH(l24w7%PuIr(JecgX(Y=Yl4Hu3qB9Id^76?HPSpK&g^aovze4_+Iq3ng1f045}G#=FpY$^I1r z8vmyX;J@IpmkyaE6(zzY=;L>r9%v+>yYh@|ro5#`&5cKjTem;3AUQ7hYK z8`-BNhLf`M`}Q0SEpsL{hJE5AMgu^Y>du{S&cMSRvJtY4jAwIz=o`EugY-7jt^(c9 zEln~yC(4^!mW7mFSDalH6|addl2`2}oAm3?KWCl2wrsuLt6P9E92FqmAqcR^#6_6t z(_xUms%LoNiy;?2$3+%O+|NC`VB%CRDky=SkX|yi$i;`+NO}5mNV+_D*G`cbDKYr< z^3m|di*WNoxIq*UZXWix?QPI~XdU>+FFAhKs&w#;rFBA`VYx+Srh=TvzpHeMgmTOmo^vWc{u#aGvTTd_B;6lp=Q3&<4l#D zoBypOMB!t6B{B7;zP}UvTbiFMg`73)KBX+OGTP3G441f{rIE_{aUWRRI|OZAQW!S{ z?W(3Nl26x-?dE&AW)XqGi+&!=aWUfzn|OOWj2*Esyl3NF6b*{ODmqFU-(@@=Y>4gG z4s_q&jMF95e2aP&rKvM1?>e%;-uR7m7!QE7ru0Z!;(wRUpouV+xcgbyUB00D@zp9R z?Hrpux>vVM=Mt3@$EVsHpeC4OOhZ$o`Z1tz{?g@7*XLhT;-q%sVO^W|rLUUDHozRf zE9*lJ`d*?_!P({?K)}f=X> transportClientPlugins() { - return Collections.>singleton(XPackPlugin.class); + return Arrays.asList(XPackClientPlugin.class); } + } diff --git a/qa/core-rest-tests-with-security/build.gradle b/qa/core-rest-tests-with-security/build.gradle index e07c820312b..53af05e9624 100644 --- a/qa/core-rest-tests-with-security/build.gradle +++ b/qa/core-rest-tests-with-security/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') } integTest { diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 4235a926d12..615ba0af634 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -11,8 +11,12 @@ apply plugin: 'elasticsearch.build' test.enabled = false dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:watcher', configuration: 'runtime') + + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') } Closure waitWithAuth = { NodeInfo node, AntBuilder ant -> @@ -113,7 +117,7 @@ subprojects { String output = "generated-resources/${project.name}" task copyTestNodeKeystore(type: Copy) { - from project(':x-pack-elasticsearch:plugin') + from project(':x-pack-elasticsearch:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') into outputDir } @@ -236,22 +240,24 @@ subprojects { check.dependsOn(integTest) dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:watcher', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') } // copy x-pack plugin info so it is on the classpath and security manager has the right permissions task copyXPackRestSpec(type: Copy) { dependsOn(project.configurations.restSpec, 'processTestResources') - from project(':x-pack-elasticsearch:plugin').sourceSets.test.resources + from project(':x-pack-elasticsearch:plugin:core').sourceSets.test.resources include 'rest-api-spec/api/**' into project.sourceSets.test.output.resourcesDir } task copyXPackPluginProps(type: Copy) { dependsOn(copyXPackRestSpec) - from project(':x-pack-elasticsearch:plugin').file('src/main/plugin-metadata') - from project(':x-pack-elasticsearch:plugin').tasks.pluginProperties + from project(':x-pack-elasticsearch:plugin:core').file('src/main/plugin-metadata') + from project(':x-pack-elasticsearch:plugin:core').tasks.pluginProperties into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps) diff --git a/qa/ml-basic-multi-node/build.gradle b/qa/ml-basic-multi-node/build.gradle index e6e21dc9336..510ff253170 100644 --- a/qa/ml-basic-multi-node/build.gradle +++ b/qa/ml-basic-multi-node/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:ml', configuration: 'runtime') } integTestCluster { diff --git a/qa/ml-disabled/build.gradle b/qa/ml-disabled/build.gradle index 24617e3124e..fad2844da3b 100644 --- a/qa/ml-disabled/build.gradle +++ b/qa/ml-disabled/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:ml', configuration: 'runtime') } integTestCluster { diff --git a/qa/ml-no-bootstrap-tests/build.gradle b/qa/ml-no-bootstrap-tests/build.gradle index a46a69868d7..2ad3a1b3a6a 100644 --- a/qa/ml-no-bootstrap-tests/build.gradle +++ b/qa/ml-no-bootstrap-tests/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'elasticsearch.standalone-test' 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:ml', configuration: 'runtime') } diff --git a/qa/ml-single-node-tests/build.gradle b/qa/ml-single-node-tests/build.gradle index c1cc1a1d518..18e2accfa9d 100644 --- a/qa/ml-single-node-tests/build.gradle +++ b/qa/ml-single-node-tests/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:ml', configuration: 'runtime') } integTestCluster { diff --git a/qa/multi-cluster-search-security/build.gradle b/qa/multi-cluster-search-security/build.gradle index 94c8d056ccc..11587ada251 100644 --- a/qa/multi-cluster-search-security/build.gradle +++ b/qa/multi-cluster-search-security/build.gradle @@ -3,8 +3,8 @@ import org.elasticsearch.gradle.test.RestIntegTestTask apply plugin: 'elasticsearch.standalone-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') } task remoteClusterTest(type: RestIntegTestTask) { diff --git a/qa/multi-node/build.gradle b/qa/multi-node/build.gradle index 4d43da6f1be..746d08878ef 100644 --- a/qa/multi-node/build.gradle +++ b/qa/multi-node/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } integTestCluster { diff --git a/qa/openldap-tests/build.gradle b/qa/openldap-tests/build.gradle index 11287e75e78..52a984943b9 100644 --- a/qa/openldap-tests/build.gradle +++ b/qa/openldap-tests/build.gradle @@ -2,8 +2,9 @@ apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.vagrantsupport' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') } task openLdapFixture { diff --git a/qa/openldap-tests/src/test/java/org/elasticsearch/test/OpenLdapTests.java b/qa/openldap-tests/src/test/java/org/elasticsearch/test/OpenLdapTests.java index 02cd9a8ec58..7fa1fcafb05 100644 --- a/qa/openldap-tests/src/test/java/org/elasticsearch/test/OpenLdapTests.java +++ b/qa/openldap-tests/src/test/java/org/elasticsearch/test/OpenLdapTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapSearchScope; import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; import org.elasticsearch.xpack.security.authc.ldap.support.LdapTestCase; import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; +import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactorySettings; import org.elasticsearch.xpack.ssl.SSLService; import org.elasticsearch.xpack.ssl.VerificationMode; import org.junit.After; @@ -164,7 +165,7 @@ public class OpenLdapTests extends ESTestCase { .put(buildLdapSettings(OPEN_LDAP_URL, userTemplate, groupSearchBase, LdapSearchScope.SUB_TREE)) .put("group_search.filter", "(objectClass=*)") .put("ssl.verification_mode", VerificationMode.CERTIFICATE) - .put(SessionFactory.TIMEOUT_TCP_READ_SETTING, "1ms") //1 millisecond + .put(SessionFactorySettings.TIMEOUT_TCP_READ_SETTING, "1ms") //1 millisecond .build(); RealmConfig config = new RealmConfig("oldap-test", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY)); diff --git a/qa/openldap-tests/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverTests.java b/qa/openldap-tests/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverTests.java index fd3ae074cd5..efe6bc63608 100644 --- a/qa/openldap-tests/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverTests.java +++ b/qa/openldap-tests/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverTests.java @@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @SuppressWarnings("unchecked") -public class SearchGroupsResolverTests extends GroupsResolverTestCase { + public class SearchGroupsResolverTests extends GroupsResolverTestCase { private static final String BRUCE_BANNER_DN = "uid=hulk,ou=people,dc=oldap,dc=test,dc=elasticsearch,dc=com"; diff --git a/qa/reindex-tests-with-security/build.gradle b/qa/reindex-tests-with-security/build.gradle index bb46e520567..5cb95c6999b 100644 --- a/qa/reindex-tests-with-security/build.gradle +++ b/qa/reindex-tests-with-security/build.gradle @@ -2,8 +2,9 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') testCompile project(path: ':modules:reindex') } diff --git a/qa/reindex-tests-with-security/src/test/java/org/elasticsearch/xpack/security/ReindexWithSecurityIT.java b/qa/reindex-tests-with-security/src/test/java/org/elasticsearch/xpack/security/ReindexWithSecurityIT.java index 570058dfd66..5da824d388a 100644 --- a/qa/reindex-tests-with-security/src/test/java/org/elasticsearch/xpack/security/ReindexWithSecurityIT.java +++ b/qa/reindex-tests-with-security/src/test/java/org/elasticsearch/xpack/security/ReindexWithSecurityIT.java @@ -5,6 +5,8 @@ */ package org.elasticsearch.xpack.security; +import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; +import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.index.reindex.BulkByScrollResponse; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; @@ -16,21 +18,41 @@ import org.elasticsearch.index.reindex.ReindexPlugin; import org.elasticsearch.index.reindex.UpdateByQueryAction; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.SecurityIntegTestCase; +import org.junit.Before; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.stream.Collectors; + +import static org.hamcrest.core.IsCollectionContaining.hasItem; public class ReindexWithSecurityIT extends SecurityIntegTestCase { @Override protected Settings externalClusterClientSettings() { Settings.Builder builder = Settings.builder().put(super.externalClusterClientSettings()); - builder.put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4); - builder.put(Security.USER_SETTING.getKey(), "test_admin:x-pack-test-password"); + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4); + builder.put(SecurityField.USER_SETTING.getKey(), "test_admin:x-pack-test-password"); return builder.build(); } + /** + * TODO: this entire class should be removed. SecurityIntegTestCase is meant for tests, but we run against real xpack + */ + @Override + public void doAssertXPackIsInstalled() { + NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); + for (NodeInfo nodeInfo : nodeInfos.getNodes()) { + // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? +// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2)); + Collection pluginNames = + nodeInfo.getPlugins().getPluginInfos().stream().map(p -> p.getClassname()).collect(Collectors.toList()); + assertThat("plugin [" + Security.class.getName() + "] not found in [" + pluginNames + "]", pluginNames, + hasItem(Security.class.getName())); + } + } + public void testDeleteByQuery() { createIndicesWithRandomAliases("test1", "test2", "test3"); diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index 8d85f892724..eb2e6c7d12c 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -10,8 +10,9 @@ apply plugin: 'elasticsearch.build' test.enabled = false dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') // to be moved in a later commit } Closure waitWithAuth = { NodeInfo node, AntBuilder ant -> @@ -101,7 +102,7 @@ subprojects { String output = "generated-resources/${project.name}" task copyTestNodeKeystore(type: Copy) { - from project(':x-pack-elasticsearch:plugin') + from project(':x-pack-elasticsearch:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') into outputDir } @@ -267,8 +268,9 @@ subprojects { check.dependsOn(integTest) dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + 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:watcher') } compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked" @@ -276,15 +278,15 @@ subprojects { // copy x-pack plugin info so it is on the classpath and security manager has the right permissions task copyXPackRestSpec(type: Copy) { dependsOn(project.configurations.restSpec, 'processTestResources') - from project(':x-pack-elasticsearch:plugin').sourceSets.test.resources + from project(':x-pack-elasticsearch:plugin:core').sourceSets.test.resources include 'rest-api-spec/api/**' into project.sourceSets.test.output.resourcesDir } task copyXPackPluginProps(type: Copy) { dependsOn(copyXPackRestSpec) - from project(':x-pack-elasticsearch:plugin').file('src/main/plugin-metadata') - from project(':x-pack-elasticsearch:plugin').tasks.pluginProperties + from project(':x-pack-elasticsearch:plugin:core').file('src/main/plugin-metadata') + from project(':x-pack-elasticsearch:plugin:core').tasks.pluginProperties into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps) diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java index 5f5cf6a9b46..45979427174 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java @@ -16,10 +16,10 @@ import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; -import org.elasticsearch.xpack.security.SecurityLifecycleService; +import org.elasticsearch.xpack.security.SecurityLifecycleServiceField; import org.junit.Before; import java.io.IOException; @@ -28,14 +28,14 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_TEMPLATE_NAME; +import static org.elasticsearch.xpack.security.SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME; import static org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue; import static org.hamcrest.Matchers.greaterThanOrEqualTo; public class TokenBackwardsCompatibilityIT extends ESRestTestCase { private static final String BASIC_AUTH_VALUE = - basicAuthHeaderValue("test_user", SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + basicAuthHeaderValue("test_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); @Override protected boolean preserveIndicesUponCompletion() { @@ -82,7 +82,7 @@ public class TokenBackwardsCompatibilityIT extends ESRestTestCase { @Before public void setupForTests() throws Exception { - final String template = SecurityLifecycleService.SECURITY_TEMPLATE_NAME; + final String template = SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME; awaitBusy(() -> { try { return adminClient().performRequest("HEAD", "_template/" + template).getStatusLine().getStatusCode() == 200; diff --git a/qa/security-client-tests/build.gradle b/qa/security-client-tests/build.gradle index b184ea62b3b..e003310864a 100644 --- a/qa/security-client-tests/build.gradle +++ b/qa/security-client-tests/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:transport-client', configuration: 'runtime') } String outputDir = "generated-resources/${project.name}" task copyXPackPluginProps(type: Copy) { - from project(':x-pack-elasticsearch:plugin').file('src/main/plugin-metadata') - from project(':x-pack-elasticsearch:plugin').tasks.pluginProperties + from project(':x-pack-elasticsearch:plugin:core').file('src/main/plugin-metadata') + from project(':x-pack-elasticsearch:plugin:core').tasks.pluginProperties into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps) diff --git a/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java b/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java index b02f75943ab..820d21bc25c 100644 --- a/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java +++ b/qa/security-client-tests/src/test/java/org/elasticsearch/xpack/security/qa/SecurityTransportClientIT.java @@ -15,10 +15,11 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; -import org.elasticsearch.xpack.security.Security; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; +import org.elasticsearch.xpack.security.SecurityField; import java.util.Collection; import java.util.Collections; @@ -39,14 +40,14 @@ public class SecurityTransportClientIT extends ESIntegTestCase { @Override protected Settings externalClusterClientSettings() { return Settings.builder() - .put(Security.USER_SETTING.getKey(), ADMIN_USER_PW) + .put(SecurityField.USER_SETTING.getKey(), ADMIN_USER_PW) .put(NetworkModule.TRANSPORT_TYPE_KEY, "security4") .build(); } @Override protected Collection> transportClientPlugins() { - return Collections.singletonList(XPackPlugin.class); + return Collections.singletonList(XPackClientPlugin.class); } public void testThatTransportClientWithoutAuthenticationDoesNotWork() throws Exception { @@ -61,7 +62,7 @@ public class SecurityTransportClientIT extends ESIntegTestCase { public void testThatTransportClientAuthenticationWithTransportClientRole() throws Exception { Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), TRANSPORT_USER_PW) + .put(SecurityField.USER_SETTING.getKey(), TRANSPORT_USER_PW) .build(); try (TransportClient client = transportClient(settings)) { boolean connected = awaitBusy(() -> { @@ -83,7 +84,7 @@ public class SecurityTransportClientIT extends ESIntegTestCase { public void testTransportClientWithAdminUser() throws Exception { final boolean useTransportUser = randomBoolean(); Settings settings = Settings.builder() - .put(Security.USER_SETTING.getKey(), useTransportUser ? TRANSPORT_USER_PW : ADMIN_USER_PW) + .put(SecurityField.USER_SETTING.getKey(), useTransportUser ? TRANSPORT_USER_PW : ADMIN_USER_PW) .build(); try (TransportClient client = transportClient(settings)) { boolean connected = awaitBusy(() -> { diff --git a/qa/security-example-extension/build.gradle b/qa/security-example-extension/build.gradle index c308fa88f79..b532f3fba41 100644 --- a/qa/security-example-extension/build.gradle +++ b/qa/security-example-extension/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'elasticsearch.build' dependencies { provided "org.elasticsearch:elasticsearch:${versions.elasticsearch}" - provided project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + provided project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}" testCompile project(path: ':x-pack-elasticsearch:transport-client', configuration: 'runtime') @@ -27,8 +27,8 @@ Map generateSubstitutions() { String outputDir = "generated-resources/${project.name}" task copyXPackPluginProps(type: Copy) { - from project(':x-pack-elasticsearch:plugin').file('src/main/plugin-metadata') - from project(':x-pack-elasticsearch:plugin').tasks.pluginProperties + from project(':x-pack-elasticsearch:plugin:core').file('src/main/plugin-metadata') + from project(':x-pack-elasticsearch:plugin:core').tasks.pluginProperties into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps) diff --git a/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java b/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java index 3924ee332ff..3b4de438ddc 100644 --- a/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java +++ b/qa/security-example-extension/src/test/java/org/elasticsearch/example/realm/CustomRealmIT.java @@ -20,6 +20,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.env.Environment; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient; @@ -45,7 +46,7 @@ public class CustomRealmIT extends ESIntegTestCase { @Override protected Collection> transportClientPlugins() { - return Collections.>singleton(XPackPlugin.class); + return Collections.singleton(XPackClientPlugin.class); } public void testHttpConnectionWithNoAuthentication() throws Exception { diff --git a/qa/security-example-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java b/qa/security-example-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java index 4fcda0527d6..eeccf0c7b4e 100644 --- a/qa/security-example-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java +++ b/qa/security-example-extension/src/test/java/org/elasticsearch/example/role/CustomRolesProviderIT.java @@ -15,7 +15,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.example.realm.CustomRealm; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.security.client.SecurityClient; @@ -47,7 +47,7 @@ public class CustomRolesProviderIT extends ESIntegTestCase { @Override protected Collection> transportClientPlugins() { - return Collections.singleton(XPackPlugin.class); + return Collections.singleton(XPackClientPlugin.class); } public void setupTestUser(String role) { diff --git a/qa/security-migrate-tests/build.gradle b/qa/security-migrate-tests/build.gradle index abb09c06af6..860c72c8fa6 100644 --- a/qa/security-migrate-tests/build.gradle +++ b/qa/security-migrate-tests/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:security', configuration: 'runtime') testCompile project(path: ':x-pack-elasticsearch:transport-client', configuration: 'runtime') } diff --git a/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java b/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java index 410202ef60c..2a74ed4d9c5 100644 --- a/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java +++ b/qa/security-migrate-tests/src/test/java/org/elasticsearch/xpack/security/MigrateToolTestCase.java @@ -71,7 +71,7 @@ public abstract class MigrateToolTestCase extends LuceneTestCase { .put("cluster.name", "qa_migrate_tests_" + counter.getAndIncrement()) .put("client.transport.ignore_cluster_name", true) .put("path.home", tempDir) - .put(Security.USER_SETTING.getKey(), "transport_user:x-pack-test-password") + .put(SecurityField.USER_SETTING.getKey(), "transport_user:x-pack-test-password") .build(); TransportClient client = new PreBuiltXPackTransportClient(clientSettings).addTransportAddresses(transportAddresses); diff --git a/qa/security-setup-password-tests/build.gradle b/qa/security-setup-password-tests/build.gradle index 26ef806bd0c..e1b74de5aab 100644 --- a/qa/security-setup-password-tests/build.gradle +++ b/qa/security-setup-password-tests/build.gradle @@ -2,8 +2,9 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') } integTestRunner { diff --git a/qa/security-tools-tests/build.gradle b/qa/security-tools-tests/build.gradle new file mode 100644 index 00000000000..b3691d4960f --- /dev/null +++ b/qa/security-tools-tests/build.gradle @@ -0,0 +1,14 @@ +apply plugin: 'elasticsearch.standalone-test' + +dependencies { + testCompile project(':x-pack-elasticsearch:plugin:security') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts') + testCompile 'com.google.jimfs:jimfs:1.1' + testCompile 'com.google.guava:guava:16.0.1' +} + +// add test resources from security, so certificate tool tests can use example certs +sourceSets.test.resources.srcDirs(project(':x-pack-elasticsearch:plugin:security').sourceSets.test.resources.srcDirs) + +// these are just tests, no need to audit +thirdPartyAudit.enabled = false diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java similarity index 94% rename from plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java index 65711f43575..39a8d97b528 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java +++ b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/authc/file/tool/UsersToolTests.java @@ -18,9 +18,9 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.security.authc.support.Hasher; import org.elasticsearch.xpack.security.authz.store.ReservedRolesStore; import org.elasticsearch.xpack.security.user.ElasticUser; @@ -67,11 +67,11 @@ public class UsersToolTests extends CommandTestCase { public void setupHome() throws IOException { Path homeDir = jimfs.getPath("eshome"); IOUtils.rm(homeDir); - confDir = homeDir.resolve("config").resolve(XpackField.NAME); + confDir = homeDir.resolve("config").resolve(XPackField.NAME); Files.createDirectories(confDir); - String defaultPassword = SecuritySettingsSource.TEST_PASSWORD; + String defaultPassword = SecuritySettingsSourceField.TEST_PASSWORD; Files.write(confDir.resolve("users"), Arrays.asList( - "existing_user:" + new String(Hasher.BCRYPT.hash(SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)), + "existing_user:" + new String(Hasher.BCRYPT.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)), "existing_user2:" + new String(Hasher.BCRYPT.hash(new SecureString((defaultPassword + "2").toCharArray()))), "existing_user3:" + new String(Hasher.BCRYPT.hash(new SecureString((defaultPassword + "3").toCharArray()))) ), StandardCharsets.UTF_8); @@ -324,20 +324,20 @@ public class UsersToolTests extends CommandTestCase { } public void testUseraddNoPassword() throws Exception { - terminal.addSecretInput(SecuritySettingsSource.TEST_PASSWORD); - terminal.addSecretInput(SecuritySettingsSource.TEST_PASSWORD); + terminal.addSecretInput(SecuritySettingsSourceField.TEST_PASSWORD); + terminal.addSecretInput(SecuritySettingsSourceField.TEST_PASSWORD); execute("useradd", pathHomeParameter, fileTypeParameter, "username"); - assertUser("username", SecuritySettingsSource.TEST_PASSWORD); + assertUser("username", SecuritySettingsSourceField.TEST_PASSWORD); } public void testUseraddPasswordOption() throws Exception { - execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSource.TEST_PASSWORD); - assertUser("username", SecuritySettingsSource.TEST_PASSWORD); + execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSourceField.TEST_PASSWORD); + assertUser("username", SecuritySettingsSourceField.TEST_PASSWORD); } public void testUseraddUserExists() throws Exception { UserException e = expectThrows(UserException.class, () -> { - execute("useradd", pathHomeParameter, fileTypeParameter, "existing_user", "-p", SecuritySettingsSource.TEST_PASSWORD); + execute("useradd", pathHomeParameter, fileTypeParameter, "existing_user", "-p", SecuritySettingsSourceField.TEST_PASSWORD); }); assertEquals(ExitCodes.CODE_ERROR, e.exitCode); assertEquals("User [existing_user] already exists", e.getMessage()); @@ -346,7 +346,7 @@ public class UsersToolTests extends CommandTestCase { public void testUseraddReservedUser() throws Exception { final String name = randomFrom(ElasticUser.NAME, KibanaUser.NAME); UserException e = expectThrows(UserException.class, () -> { - execute("useradd", pathHomeParameter, fileTypeParameter, name, "-p", SecuritySettingsSource.TEST_PASSWORD); + execute("useradd", pathHomeParameter, fileTypeParameter, name, "-p", SecuritySettingsSourceField.TEST_PASSWORD); }); assertEquals(ExitCodes.DATA_ERROR, e.exitCode); assertEquals("Invalid username [" + name + "]... Username [" + name + "] is reserved and may not be used.", e.getMessage()); @@ -355,7 +355,7 @@ public class UsersToolTests extends CommandTestCase { public void testUseraddNoRoles() throws Exception { Files.delete(confDir.resolve("users_roles")); Files.createFile(confDir.resolve("users_roles")); - execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSource.TEST_PASSWORD); + execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSourceField.TEST_PASSWORD); List lines = Files.readAllLines(confDir.resolve("users_roles"), StandardCharsets.UTF_8); assertTrue(lines.toString(), lines.isEmpty()); } @@ -375,7 +375,7 @@ public class UsersToolTests extends CommandTestCase { public void testPasswdUnknownUser() throws Exception { UserException e = expectThrows(UserException.class, () -> { - execute("passwd", pathHomeParameter, fileTypeParameter, "unknown", "-p", SecuritySettingsSource.TEST_PASSWORD); + execute("passwd", pathHomeParameter, fileTypeParameter, "unknown", "-p", SecuritySettingsSourceField.TEST_PASSWORD); }); assertEquals(ExitCodes.NO_USER, e.exitCode); assertTrue(e.getMessage(), e.getMessage().contains("User [unknown] doesn't exist")); @@ -421,7 +421,7 @@ public class UsersToolTests extends CommandTestCase { } public void testRolesRemoveLeavesExisting() throws Exception { - execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSource.TEST_PASSWORD, + execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSourceField.TEST_PASSWORD, "-r", "test_admin"); execute("roles", pathHomeParameter, fileTypeParameter, "existing_user", "-r", "test_admin"); assertRole("test_admin", "username"); @@ -464,7 +464,7 @@ public class UsersToolTests extends CommandTestCase { } public void testListUnknownRoles() throws Exception { - execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSource.TEST_PASSWORD, + execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSourceField.TEST_PASSWORD, "-r", "test_r1,r2,r3"); String output = execute("list", pathHomeParameter, fileTypeParameter, "username"); assertTrue(output, output.contains("username")); @@ -492,12 +492,12 @@ public class UsersToolTests extends CommandTestCase { public void testUserAddNoConfig() throws Exception { Path homeDir = jimfs.getPath("eshome"); - Path xpackConfDir = homeDir.resolve("config").resolve(XpackField.NAME); + Path xpackConfDir = homeDir.resolve("config").resolve(XPackField.NAME); IOUtils.rm(confDir); pathHomeParameter = "-Epath.home=" + homeDir; fileTypeParameter = "-Expack.security.authc.realms.file.type=file"; UserException e = expectThrows(UserException.class, () -> { - execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSource.TEST_PASSWORD); + execute("useradd", pathHomeParameter, fileTypeParameter, "username", "-p", SecuritySettingsSourceField.TEST_PASSWORD); }); assertEquals(ExitCodes.CONFIG, e.exitCode); assertThat(e.getMessage(), containsString("is the configuration directory for Elasticsearch and create directory")); @@ -505,7 +505,7 @@ public class UsersToolTests extends CommandTestCase { public void testUserListNoConfig() throws Exception { Path homeDir = jimfs.getPath("eshome"); - Path xpackConfDir = homeDir.resolve("config").resolve(XpackField.NAME); + Path xpackConfDir = homeDir.resolve("config").resolve(XPackField.NAME); IOUtils.rm(confDir); pathHomeParameter = "-Epath.home=" + homeDir; fileTypeParameter = "-Expack.security.authc.realms.file.type=file"; @@ -518,7 +518,7 @@ public class UsersToolTests extends CommandTestCase { public void testUserDelNoConfig() throws Exception { Path homeDir = jimfs.getPath("eshome"); - Path xpackConfDir = homeDir.resolve("config").resolve(XpackField.NAME); + Path xpackConfDir = homeDir.resolve("config").resolve(XPackField.NAME); IOUtils.rm(confDir); pathHomeParameter = "-Epath.home=" + homeDir; fileTypeParameter = "-Expack.security.authc.realms.file.type=file"; @@ -531,7 +531,7 @@ public class UsersToolTests extends CommandTestCase { public void testListUserRolesNoConfig() throws Exception { Path homeDir = jimfs.getPath("eshome"); - Path xpackConfDir = homeDir.resolve("config").resolve(XpackField.NAME); + Path xpackConfDir = homeDir.resolve("config").resolve(XPackField.NAME); IOUtils.rm(confDir); pathHomeParameter = "-Epath.home=" + homeDir; fileTypeParameter = "-Expack.security.authc.realms.file.type=file"; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java index d7fa84a6656..11beb494fde 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java +++ b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyToolTests.java @@ -15,7 +15,7 @@ import org.elasticsearch.common.io.PathUtilsForTesting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; import org.junit.After; import java.nio.file.FileSystem; @@ -77,7 +77,7 @@ public class SystemKeyToolTests extends CommandTestCase { public void testGeneratePathInSettings() throws Exception { final Path homeDir = initFileSystem(false); - Path xpackConf = homeDir.resolve("config").resolve(XpackField.NAME); + Path xpackConf = homeDir.resolve("config").resolve(XPackField.NAME); Files.createDirectories(xpackConf); execute("-Epath.home=" + homeDir.toString()); byte[] bytes = Files.readAllBytes(xpackConf.resolve("system_key")); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/FileAttributesCheckerTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/support/FileAttributesCheckerTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/FileAttributesCheckerTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/support/FileAttributesCheckerTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java similarity index 100% rename from plugin/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/security/support/SecurityFilesTests.java diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java similarity index 98% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java index d0850c1016c..cf0e89fa104 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java +++ b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateGenerateToolTests.java @@ -5,6 +5,41 @@ */ package org.elasticsearch.xpack.ssl; +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Jimfs; +import org.apache.lucene.util.IOUtils; +import org.bouncycastle.asn1.ASN1ObjectIdentifier; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.ASN1String; +import org.bouncycastle.asn1.DEROctetString; +import org.bouncycastle.asn1.DERTaggedObject; +import org.bouncycastle.asn1.pkcs.Attribute; +import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; +import org.bouncycastle.asn1.x509.Extension; +import org.bouncycastle.asn1.x509.Extensions; +import org.bouncycastle.asn1.x509.GeneralName; +import org.bouncycastle.asn1.x509.GeneralNames; +import org.bouncycastle.cert.X509CertificateHolder; +import org.bouncycastle.openssl.PEMEncryptedKeyPair; +import org.bouncycastle.openssl.PEMParser; +import org.bouncycastle.pkcs.PKCS10CertificationRequest; +import org.elasticsearch.cli.MockTerminal; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.SuppressForbidden; +import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.network.NetworkAddress; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.TestEnvironment; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.SecuritySettingsSourceField; +import org.elasticsearch.test.SecurityTestsUtils; +import org.elasticsearch.xpack.ssl.CertificateGenerateTool.CAInfo; +import org.elasticsearch.xpack.ssl.CertificateGenerateTool.CertificateInformation; +import org.elasticsearch.xpack.ssl.CertificateGenerateTool.Name; +import org.hamcrest.Matchers; +import org.junit.After; + import javax.security.auth.x500.X500Principal; import java.io.IOException; import java.io.InputStream; @@ -38,40 +73,6 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; -import com.google.common.jimfs.Configuration; -import com.google.common.jimfs.Jimfs; -import org.apache.lucene.util.IOUtils; -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1String; -import org.bouncycastle.asn1.DEROctetString; -import org.bouncycastle.asn1.DERTaggedObject; -import org.bouncycastle.asn1.pkcs.Attribute; -import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.Extensions; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.openssl.PEMEncryptedKeyPair; -import org.bouncycastle.openssl.PEMParser; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.elasticsearch.cli.MockTerminal; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.SuppressForbidden; -import org.elasticsearch.common.io.PathUtils; -import org.elasticsearch.common.network.NetworkAddress; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; -import org.elasticsearch.xpack.ssl.CertificateGenerateTool.CAInfo; -import org.elasticsearch.xpack.ssl.CertificateGenerateTool.CertificateInformation; -import org.elasticsearch.xpack.ssl.CertificateGenerateTool.Name; -import org.hamcrest.Matchers; -import org.junit.After; - import static org.elasticsearch.test.TestMatchers.pathExists; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -82,6 +83,7 @@ import static org.hamcrest.Matchers.notNullValue; /** * Unit tests for the tool used to simplify SSL certificate generation */ +// TODO baz - fix this to work in intellij+java9, its complaining about java.sql.Date not being on the classpath public class CertificateGenerateToolTests extends ESTestCase { private FileSystem jimfs; @@ -266,7 +268,7 @@ public class CertificateGenerateToolTests extends ESTestCase { X509Certificate caCert = CertUtils.generateCACertificate(new X500Principal("CN=test ca"), keyPair, days); final boolean generatedCa = randomBoolean(); - final char[] keyPassword = randomBoolean() ? SecuritySettingsSource.TEST_PASSWORD.toCharArray() : null; + final char[] keyPassword = randomBoolean() ? SecuritySettingsSourceField.TEST_PASSWORD.toCharArray() : null; final char[] pkcs12Password = randomBoolean() ? randomAlphaOfLengthBetween(1, 12).toCharArray() : null; assertFalse(Files.exists(outputFile)); CAInfo caInfo = new CAInfo(caCert, keyPair.getPrivate(), generatedCa, keyPassword); @@ -308,7 +310,7 @@ public class CertificateGenerateToolTests extends ESTestCase { try (Reader reader = Files.newBufferedReader(zipRoot.resolve("ca").resolve("ca.key"))) { PrivateKey privateKey = CertUtils.readPrivateKey(reader, () -> keyPassword != null ? - SecuritySettingsSource.TEST_PASSWORD.toCharArray() : null); + SecuritySettingsSourceField.TEST_PASSWORD.toCharArray() : null); assertEquals(caInfo.privateKey, privateKey); } } else { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java similarity index 97% rename from plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java rename to qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java index 52af83d69c0..8dbd75fcf03 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java +++ b/qa/security-tools-tests/src/test/java/org/elasticsearch/xpack/ssl/CertificateToolTests.java @@ -5,6 +5,50 @@ */ package org.elasticsearch.xpack.ssl; +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Jimfs; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.apache.lucene.util.IOUtils; +import org.bouncycastle.asn1.ASN1ObjectIdentifier; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.ASN1String; +import org.bouncycastle.asn1.ASN1TaggedObject; +import org.bouncycastle.asn1.DEROctetString; +import org.bouncycastle.asn1.pkcs.Attribute; +import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; +import org.bouncycastle.asn1.x509.Extension; +import org.bouncycastle.asn1.x509.Extensions; +import org.bouncycastle.asn1.x509.GeneralName; +import org.bouncycastle.asn1.x509.GeneralNames; +import org.bouncycastle.cert.X509CertificateHolder; +import org.bouncycastle.openssl.PEMEncryptedKeyPair; +import org.bouncycastle.openssl.PEMParser; +import org.bouncycastle.pkcs.PKCS10CertificationRequest; +import org.elasticsearch.cli.MockTerminal; +import org.elasticsearch.cli.Terminal; +import org.elasticsearch.cli.UserException; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.SuppressForbidden; +import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.network.NetworkAddress; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.CollectionUtils; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.TestEnvironment; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.SecuritySettingsSourceField; +import org.elasticsearch.test.SecurityTestsUtils; +import org.elasticsearch.test.TestMatchers; +import org.elasticsearch.xpack.ssl.CertificateTool.CAInfo; +import org.elasticsearch.xpack.ssl.CertificateTool.CertificateAuthorityCommand; +import org.elasticsearch.xpack.ssl.CertificateTool.CertificateCommand; +import org.elasticsearch.xpack.ssl.CertificateTool.CertificateInformation; +import org.elasticsearch.xpack.ssl.CertificateTool.GenerateCertificateCommand; +import org.elasticsearch.xpack.ssl.CertificateTool.Name; +import org.hamcrest.Matchers; +import org.junit.After; + import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509ExtendedKeyManager; @@ -42,48 +86,6 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; -import com.google.common.jimfs.Configuration; -import com.google.common.jimfs.Jimfs; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.apache.lucene.util.IOUtils; -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1String; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DEROctetString; -import org.bouncycastle.asn1.pkcs.Attribute; -import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.Extensions; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.openssl.PEMEncryptedKeyPair; -import org.bouncycastle.openssl.PEMParser; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.elasticsearch.cli.MockTerminal; -import org.elasticsearch.cli.Terminal; -import org.elasticsearch.cli.UserException; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.SuppressForbidden; -import org.elasticsearch.common.io.PathUtils; -import org.elasticsearch.common.network.NetworkAddress; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.CollectionUtils; -import org.elasticsearch.env.Environment; -import org.elasticsearch.env.TestEnvironment; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.SecuritySettingsSource; -import org.elasticsearch.xpack.ssl.CertificateTool.CAInfo; -import org.elasticsearch.xpack.ssl.CertificateTool.CertificateAuthorityCommand; -import org.elasticsearch.xpack.ssl.CertificateTool.CertificateCommand; -import org.elasticsearch.xpack.ssl.CertificateTool.CertificateInformation; -import org.elasticsearch.xpack.ssl.CertificateTool.GenerateCertificateCommand; -import org.elasticsearch.xpack.ssl.CertificateTool.Name; -import org.hamcrest.Matchers; -import org.junit.After; - import static org.elasticsearch.test.TestMatchers.pathExists; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.containsString; @@ -295,7 +297,7 @@ public class CertificateToolTests extends ESTestCase { final boolean generatedCa = randomBoolean(); final boolean keepCaKey = generatedCa && randomBoolean(); - final String keyPassword = randomBoolean() ? SecuritySettingsSource.TEST_PASSWORD : null; + final String keyPassword = randomBoolean() ? SecuritySettingsSourceField.TEST_PASSWORD : null; assertFalse(Files.exists(outputFile)); CAInfo caInfo = new CAInfo(caCert, keyPair.getPrivate(), generatedCa, keyPassword == null ? null : keyPassword.toCharArray()); @@ -375,7 +377,7 @@ public class CertificateToolTests extends ESTestCase { GeneralNames.fromExtensions(x509CertHolder.getExtensions(), Extension.subjectAlternativeName); assertSubjAltNames(subjAltNames, certInfo); } - assertThat(p12, not(pathExists(p12))); + assertThat(p12, Matchers.not(TestMatchers.pathExists(p12))); } } } @@ -561,7 +563,7 @@ public class CertificateToolTests extends ESTestCase { ); caCommand.execute(terminal, caOptions, env); - assertThat(caFile, pathExists(caFile)); + assertThat(caFile, TestMatchers.pathExists(caFile)); final GenerateCertificateCommand gen1Command = new PathAwareGenerateCertificateCommand(caFile, node1File); final OptionSet gen1Options = gen1Command.getParser().parse( @@ -576,7 +578,7 @@ public class CertificateToolTests extends ESTestCase { "-name", "node01"); gen1Command.execute(terminal, gen1Options, env); - assertThat(node1File, pathExists(node1File)); + assertThat(node1File, TestMatchers.pathExists(node1File)); final GenerateCertificateCommand gen2Command = new PathAwareGenerateCertificateCommand(caFile, node2File); final OptionSet gen2Options = gen2Command.getParser().parse( @@ -591,7 +593,7 @@ public class CertificateToolTests extends ESTestCase { "-name", "node02"); gen2Command.execute(terminal, gen2Options, env); - assertThat(node2File, pathExists(node2File)); + assertThat(node2File, TestMatchers.pathExists(node2File)); // Node 3 uses an auto generated CA, and therefore should not be trusted by the other nodes. final GenerateCertificateCommand gen3Command = new PathAwareGenerateCertificateCommand(null, node3File); @@ -605,7 +607,7 @@ public class CertificateToolTests extends ESTestCase { "-ip", node3Ip); gen3Command.execute(terminal, gen3Options, env); - assertThat(node3File, pathExists(node3File)); + assertThat(node3File, TestMatchers.pathExists(node3File)); final KeyStore node1KeyStore = CertUtils.readKeyStore(node1File, "PKCS12", node1Password.toCharArray()); final KeyStore node2KeyStore = CertUtils.readKeyStore(node2File, "PKCS12", node2Password.toCharArray()); @@ -677,16 +679,16 @@ public class CertificateToolTests extends ESTestCase { terminal.addSecretInput(node1Password); gen1Command.execute(terminal, gen1Options, env); - assertThat(pkcs12Zip, pathExists(pkcs12Zip)); + assertThat(pkcs12Zip, TestMatchers.pathExists(pkcs12Zip)); FileSystem zip1FS = FileSystems.newFileSystem(new URI("jar:" + pkcs12Zip.toUri()), Collections.emptyMap()); Path zip1Root = zip1FS.getPath("/"); final Path caP12 = zip1Root.resolve("ca/ca.p12"); - assertThat(caP12, pathExists(caP12)); + assertThat(caP12, TestMatchers.pathExists(caP12)); final Path node1P12 = zip1Root.resolve("node01/node01.p12"); - assertThat(node1P12, pathExists(node1P12)); + assertThat(node1P12, TestMatchers.pathExists(node1P12)); final GenerateCertificateCommand gen2Command = new PathAwareGenerateCertificateCommand(caP12, pemZip); final OptionSet gen2Options = gen2Command.getParser().parse( @@ -702,18 +704,18 @@ public class CertificateToolTests extends ESTestCase { terminal.addSecretInput(caPassword); gen2Command.execute(terminal, gen2Options, env); - assertThat(pemZip, pathExists(pemZip)); + assertThat(pemZip, TestMatchers.pathExists(pemZip)); FileSystem zip2FS = FileSystems.newFileSystem(new URI("jar:" + pemZip.toUri()), Collections.emptyMap()); Path zip2Root = zip2FS.getPath("/"); final Path ca2 = zip2Root.resolve("ca/ca.p12"); - assertThat(ca2, not(pathExists(ca2))); + assertThat(ca2, Matchers.not(TestMatchers.pathExists(ca2))); final Path node2Cert = zip2Root.resolve("node02/node02.crt"); - assertThat(node2Cert, pathExists(node2Cert)); + assertThat(node2Cert, TestMatchers.pathExists(node2Cert)); final Path node2Key = zip2Root.resolve("node02/node02.key"); - assertThat(node2Key, pathExists(node2Key)); + assertThat(node2Key, TestMatchers.pathExists(node2Key)); final KeyStore node1KeyStore = CertUtils.readKeyStore(node1P12, "PKCS12", node1Password.toCharArray()); final KeyStore node1TrustStore = node1KeyStore; diff --git a/qa/smoke-test-graph-with-security/build.gradle b/qa/smoke-test-graph-with-security/build.gradle index 459ca0db42e..4f48c21f45d 100644 --- a/qa/smoke-test-graph-with-security/build.gradle +++ b/qa/smoke-test-graph-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } // bring in graph rest test suite diff --git a/qa/smoke-test-ml-with-security/build.gradle b/qa/smoke-test-ml-with-security/build.gradle index f9c22a0ccf7..3559ae0d9b3 100644 --- a/qa/smoke-test-ml-with-security/build.gradle +++ b/qa/smoke-test-ml-with-security/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityIT.java b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityIT.java index 675781d28b4..286603010f3 100644 --- a/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityIT.java +++ b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityIT.java @@ -6,15 +6,13 @@ package org.elasticsearch.smoketest; import com.carrotsearch.randomizedtesting.annotations.Name; - import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.xpack.test.rest.XPackRestIT; - import java.util.Collections; import java.util.Map; @@ -44,7 +42,7 @@ public class MlWithSecurityIT extends XPackRestIT { @Override protected Settings restAdminSettings() { - String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING); + String token = basicAuthHeaderValue(TEST_ADMIN_USERNAME, SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING); return Settings.builder() .put(ThreadContext.PREFIX + ".Authorization", token) .build(); @@ -52,7 +50,7 @@ public class MlWithSecurityIT extends XPackRestIT { protected Map getApiCallHeaders() { return Collections.singletonMap("Authorization", basicAuthHeaderValue(TEST_ADMIN_USERNAME, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING)); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); } @Override diff --git a/qa/smoke-test-monitoring-with-watcher/build.gradle b/qa/smoke-test-monitoring-with-watcher/build.gradle index eec3a9cb17b..c9e739961f6 100644 --- a/qa/smoke-test-monitoring-with-watcher/build.gradle +++ b/qa/smoke-test-monitoring-with-watcher/build.gradle @@ -2,7 +2,9 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core') + testCompile project(path: ':x-pack-elasticsearch:plugin:watcher') + testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring') } integTestCluster { diff --git a/qa/smoke-test-plugins-ssl/build.gradle b/qa/smoke-test-plugins-ssl/build.gradle index 75b089bd22c..ebe1d754e75 100644 --- a/qa/smoke-test-plugins-ssl/build.gradle +++ b/qa/smoke-test-plugins-ssl/build.gradle @@ -14,13 +14,13 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } String outputDir = "generated-resources/${project.name}" task copyXPackPluginProps(type: Copy) { - from project(':x-pack-elasticsearch:plugin').file('src/main/plugin-metadata') - from project(':x-pack-elasticsearch:plugin').tasks.pluginProperties + from project(':x-pack-elasticsearch:plugin:core').file('src/main/plugin-metadata') + from project(':x-pack-elasticsearch:plugin:core').tasks.pluginProperties into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps) @@ -84,6 +84,7 @@ task createClientKeyStore(type: LoggedExec) { // Export the node's certificate File nodeCertificate = new File(keystoreDir, 'test-node.cert') task exportNodeCertificate(type: LoggedExec) { + dependsOn createNodeKeyStore doFirst { if (nodeCertificate.parentFile.exists() == false) { nodeCertificate.parentFile.mkdirs() @@ -115,6 +116,7 @@ task importNodeCertificateInClientKeyStore(type: LoggedExec) { // Export the client's certificate File clientCertificate = new File(keystoreDir, 'test-client.cert') task exportClientCertificate(type: LoggedExec) { + dependsOn createClientKeyStore doFirst { if (clientCertificate.parentFile.exists() == false) { clientCertificate.parentFile.mkdirs() @@ -154,9 +156,16 @@ processTestResources.dependsOn( importNodeCertificateInClientKeyStore, importClientCertificateInNodeKeyStore ) -integTestCluster.dependsOn(importClientCertificateInNodeKeyStore) +integTestCluster.dependsOn(importClientCertificateInNodeKeyStore, importNodeCertificateInClientKeyStore) -ext.pluginsCount = 1 // we install xpack explicitly + +ext.pluginsCount = 0 +project(':x-pack-elasticsearch:plugin').subprojects { Project p -> + // the meta plugin contains the individual xpack plugins + if (p.extensions.findByName('esplugin') != null) { + pluginsCount += 1 + } +} project.rootProject.subprojects.findAll { it.path.startsWith(':plugins:') }.each { subproj -> // need to get a non-decorated project object, so must re-lookup the project by path integTestCluster.plugin(subproj.path) diff --git a/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java b/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java index 6aebe61762b..72eaf19f412 100644 --- a/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java +++ b/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java @@ -11,9 +11,9 @@ import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.xpack.security.Security; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.XPackPlugin; +import org.elasticsearch.xpack.security.SecurityField; import org.junit.After; import org.junit.Before; @@ -49,8 +49,8 @@ public class SmokeTestMonitoringWithSecurityIT extends ESIntegTestCase { @Override protected Settings externalClusterClientSettings() { return Settings.builder() - .put(Security.USER_SETTING.getKey(), USER + ":" + PASS) - .put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4).build(); + .put(SecurityField.USER_SETTING.getKey(), USER + ":" + PASS) + .put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4).build(); } @Before diff --git a/qa/smoke-test-plugins/build.gradle b/qa/smoke-test-plugins/build.gradle index e03f83a9ab9..bc10dd376cf 100644 --- a/qa/smoke-test-plugins/build.gradle +++ b/qa/smoke-test-plugins/build.gradle @@ -4,10 +4,16 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } -ext.pluginsCount = 1 // we install xpack explicitly +ext.pluginsCount = 0 +project(':x-pack-elasticsearch:plugin').subprojects { Project p -> + // the meta plugin contains the individual xpack plugins + if (p.extensions.findByName('esplugin') != null) { + pluginsCount += 1 + } +} project.rootProject.subprojects.findAll { it.path.startsWith(':plugins:') }.each { subproj -> // need to get a non-decorated project object, so must re-lookup the project by path integTestCluster.plugin(subproj.path) diff --git a/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/XSmokeTestPluginsClientYamlTestSuiteIT.java b/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/XSmokeTestPluginsClientYamlTestSuiteIT.java index 42e1f26307a..c790fccaa63 100644 --- a/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/XSmokeTestPluginsClientYamlTestSuiteIT.java +++ b/qa/smoke-test-plugins/src/test/java/org/elasticsearch/smoketest/XSmokeTestPluginsClientYamlTestSuiteIT.java @@ -32,6 +32,7 @@ public class XSmokeTestPluginsClientYamlTestSuiteIT extends ESClientYamlSuiteTes @Override protected Settings restClientSettings() { + String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); return Settings.builder() .put(ThreadContext.PREFIX + ".Authorization", token) diff --git a/qa/smoke-test-security-with-mustache/build.gradle b/qa/smoke-test-security-with-mustache/build.gradle index 523146cbb52..e3a7187a2e9 100644 --- a/qa/smoke-test-security-with-mustache/build.gradle +++ b/qa/smoke-test-security-with-mustache/build.gradle @@ -2,8 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') testCompile project(path: ':modules:lang-mustache', configuration: 'runtime') } diff --git a/qa/smoke-test-watcher-with-mustache/build.gradle b/qa/smoke-test-watcher-with-mustache/build.gradle index 1b924a69133..06c54e7f8d1 100644 --- a/qa/smoke-test-watcher-with-mustache/build.gradle +++ b/qa/smoke-test-watcher-with-mustache/build.gradle @@ -2,7 +2,8 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:watcher', configuration: 'runtime') testCompile project(path: ':modules:lang-mustache', configuration: 'runtime') } diff --git a/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherWithMustacheIT.java b/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherWithMustacheIT.java index 1dec2e7bd08..0296dbc1658 100644 --- a/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherWithMustacheIT.java +++ b/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherWithMustacheIT.java @@ -10,7 +10,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.junit.After; import org.junit.Before; @@ -37,7 +37,7 @@ public class WatcherWithMustacheIT extends ESClientYamlSuiteTestCase { @Before public void startWatcher() throws Exception { - final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistry.TEMPLATE_NAMES); + final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES); assertBusy(() -> { try { getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap()); diff --git a/qa/smoke-test-watcher-with-painless/build.gradle b/qa/smoke-test-watcher-with-painless/build.gradle index 4578bae8c12..186b10b55e6 100644 --- a/qa/smoke-test-watcher-with-painless/build.gradle +++ b/qa/smoke-test-watcher-with-painless/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') testCompile project(path: ':modules:lang-painless', configuration: 'runtime') } diff --git a/qa/smoke-test-watcher-with-painless/src/test/java/org/elasticsearch/smoketest/WatcherWithPainlessIT.java b/qa/smoke-test-watcher-with-painless/src/test/java/org/elasticsearch/smoketest/WatcherWithPainlessIT.java index 6536ec6f9a5..3854a6c1a44 100644 --- a/qa/smoke-test-watcher-with-painless/src/test/java/org/elasticsearch/smoketest/WatcherWithPainlessIT.java +++ b/qa/smoke-test-watcher-with-painless/src/test/java/org/elasticsearch/smoketest/WatcherWithPainlessIT.java @@ -9,7 +9,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.junit.After; import org.junit.Before; @@ -36,7 +36,7 @@ public class WatcherWithPainlessIT extends ESClientYamlSuiteTestCase { @Before public void startWatcher() throws Exception { - final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistry.TEMPLATE_NAMES); + final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES); assertBusy(() -> { try { getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap()); diff --git a/qa/smoke-test-watcher-with-security/build.gradle b/qa/smoke-test-watcher-with-security/build.gradle index 55280b4b791..cd17ff436fe 100644 --- a/qa/smoke-test-watcher-with-security/build.gradle +++ b/qa/smoke-test-watcher-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } // bring in watcher rest test suite diff --git a/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java b/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java index e7d444c73f9..ec354fb4d42 100644 --- a/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java +++ b/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java @@ -16,7 +16,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.junit.After; import org.junit.Before; @@ -58,7 +58,7 @@ public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientY try { getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap()); - for (String template : WatcherIndexTemplateRegistry.TEMPLATE_NAMES) { + for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES) { ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template", singletonMap("name", template), emptyList(), emptyMap()); assertThat(templateExistsResponse.getStatusCode(), is(200)); diff --git a/qa/smoke-test-watcher/build.gradle b/qa/smoke-test-watcher/build.gradle index bbb87da20bd..f5a67548dbc 100644 --- a/qa/smoke-test-watcher/build.gradle +++ b/qa/smoke-test-watcher/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'runtime') } ext { diff --git a/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherClientYamlTestSuiteIT.java b/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherClientYamlTestSuiteIT.java index a1c98216146..06578b232b4 100644 --- a/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherClientYamlTestSuiteIT.java +++ b/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherClientYamlTestSuiteIT.java @@ -12,7 +12,7 @@ import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; -import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry; +import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistryField; import org.junit.After; import org.junit.Before; @@ -41,7 +41,7 @@ public class SmokeTestWatcherClientYamlTestSuiteIT extends ESClientYamlSuiteTest @Before public void startWatcher() throws Exception { - final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistry.TEMPLATE_NAMES); + final List watcherTemplates = Arrays.asList(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES); assertBusy(() -> { try { getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap()); diff --git a/qa/transport-client-tests/build.gradle b/qa/transport-client-tests/build.gradle index 4f1e0bf2473..0cdcc6e2513 100644 --- a/qa/transport-client-tests/build.gradle +++ b/qa/transport-client-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' 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:transport-client', configuration: 'runtime') } diff --git a/qa/tribe-tests-with-license/build.gradle b/qa/tribe-tests-with-license/build.gradle index ca1183656bd..5e5c3fd3fda 100644 --- a/qa/tribe-tests-with-license/build.gradle +++ b/qa/tribe-tests-with-license/build.gradle @@ -8,8 +8,17 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: ':modules:tribe', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:deprecation', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:graph', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:logstash', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:ml', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:upgrade', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:watcher', configuration: 'runtime') + testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts') + testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring', configuration: 'testArtifacts') } compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked" diff --git a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/license/TribeTransportTestCase.java b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/license/TribeTransportTestCase.java index 9f8488b33e3..700ad1f0bfe 100644 --- a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/license/TribeTransportTestCase.java +++ b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/license/TribeTransportTestCase.java @@ -33,10 +33,20 @@ import org.elasticsearch.test.NodeConfigurationSource; import org.elasticsearch.test.TestCluster; import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.tribe.TribePlugin; +import org.elasticsearch.xpack.CompositeTestingXPackPlugin; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.XpackField; +import org.elasticsearch.xpack.XPackField; +import org.elasticsearch.xpack.deprecation.Deprecation; +import org.elasticsearch.xpack.graph.Graph; +import org.elasticsearch.xpack.logstash.Logstash; import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; +import org.elasticsearch.xpack.monitoring.Monitoring; +import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.upgrade.Upgrade; +import org.elasticsearch.xpack.watcher.Watcher; import java.nio.file.Path; import java.util.ArrayList; @@ -64,12 +74,12 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put("transport.type", getTestTransportType()); List enabledFeatures = enabledFeatures(); - builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XpackField.SECURITY)); - builder.put(XPackSettings.MONITORING_ENABLED.getKey(), enabledFeatures.contains(XpackField.MONITORING)); - builder.put(XPackSettings.WATCHER_ENABLED.getKey(), enabledFeatures.contains(XpackField.WATCHER)); - builder.put(XPackSettings.GRAPH_ENABLED.getKey(), enabledFeatures.contains(XpackField.GRAPH)); - builder.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), enabledFeatures.contains(XpackField.MACHINE_LEARNING)); - builder.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); + builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XPackField.SECURITY)); + builder.put(XPackSettings.MONITORING_ENABLED.getKey(), enabledFeatures.contains(XPackField.MONITORING)); + builder.put(XPackSettings.WATCHER_ENABLED.getKey(), enabledFeatures.contains(XPackField.WATCHER)); + builder.put(XPackSettings.GRAPH_ENABLED.getKey(), enabledFeatures.contains(XPackField.GRAPH)); + builder.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), enabledFeatures.contains(XPackField.MACHINE_LEARNING)); + builder.put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false); return builder.build(); } @@ -116,16 +126,20 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { ArrayList> plugins = new ArrayList<>(); plugins.add(MockTribePlugin.class); plugins.add(TribeAwareTestZenDiscoveryPlugin.class); - plugins.add(XPackPlugin.class); + plugins.add(CompositeTestingXPackPlugin.class); plugins.add(CommonAnalysisPlugin.class); return plugins; } @Override protected final Collection> transportClientPlugins() { - return nodePlugins(); + ArrayList> plugins = new ArrayList<>(); + plugins.add(MockTribePlugin.class); + plugins.add(TribeAwareTestZenDiscoveryPlugin.class); + plugins.add(XPackClientPlugin.class); + plugins.add(CommonAnalysisPlugin.class); + return plugins; } - public void testTribeSetup() throws Exception { NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() { @Override @@ -194,21 +208,22 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { .put(internalCluster().getDefaultSettings()) .put(XPackSettings.SECURITY_ENABLED.getKey(), false) // otherwise it conflicts with mock transport .put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) - .put(MachineLearning.AUTODETECT_PROCESS.getKey(), false) + .put(MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .put("tribe.t1." + XPackSettings.SECURITY_ENABLED.getKey(), false) .put("tribe.t2." + XPackSettings.SECURITY_ENABLED.getKey(), false) .put("tribe.t1." + XPackSettings.WATCHER_ENABLED.getKey(), false) .put("tribe.t2." + XPackSettings.WATCHER_ENABLED.getKey(), false) .put("tribe.t1." + XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) .put("tribe.t2." + XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false) - .put("tribe.t1." + MachineLearning.AUTODETECT_PROCESS.getKey(), false) - .put("tribe.t2." + MachineLearning.AUTODETECT_PROCESS.getKey(), false) + .put("tribe.t1." + MachineLearningField.AUTODETECT_PROCESS.getKey(), false) + .put("tribe.t2." + MachineLearningField.AUTODETECT_PROCESS.getKey(), false) .put("node.name", "tribe_node") // make sure we can identify threads from this node .put("transport.type", getTestTransportType()) .build(); final List> mockPlugins = Arrays.asList(MockTribePlugin.class, TribeAwareTestZenDiscoveryPlugin.class, - getTestTransportPlugin(), XPackPlugin.class); + getTestTransportPlugin(), Deprecation.class, Graph.class, Logstash.class, MachineLearning.class, Monitoring.class, + Security.class, Upgrade.class, Watcher.class, XPackPlugin.class); final Node tribeNode = new MockNode(merged, mockPlugins).start(); Client tribeClient = tribeNode.client(); diff --git a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/test/LicensingTribeIT.java b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/test/LicensingTribeIT.java index d36f09fb786..d885f7de666 100644 --- a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/test/LicensingTribeIT.java +++ b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/test/LicensingTribeIT.java @@ -16,9 +16,10 @@ import org.elasticsearch.license.LicensesStatus; import org.elasticsearch.license.LicensingClient; import org.elasticsearch.license.PutLicenseResponse; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.xpack.LocalStateCompositeXPackPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.ml.MachineLearning; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.junit.AfterClass; import java.io.IOException; @@ -42,7 +43,7 @@ public class LicensingTribeIT extends ESIntegTestCase { @Override protected Collection> transportClientPlugins() { - return nodePlugins(); + return Collections.singletonList(LocalStateCompositeXPackPlugin.class); } @Override @@ -84,8 +85,6 @@ public class LicensingTribeIT extends ESIntegTestCase { builder.put(XPackSettings.WATCHER_ENABLED.getKey(), false); builder.put(XPackSettings.GRAPH_ENABLED.getKey(), false); builder.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); - // Disable native ML autodetect_process as the c++ controller won't be available - builder.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false); return builder.build(); } diff --git a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginTests.java b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginTests.java index 21834f5add4..3748900ec8b 100644 --- a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginTests.java +++ b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringPluginTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.tribe.TribePlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackSettings; +import org.elasticsearch.xpack.ml.MachineLearningField; import org.elasticsearch.xpack.monitoring.test.MonitoringIntegTestCase; import java.nio.file.Path; @@ -31,6 +32,10 @@ import static org.hamcrest.Matchers.equalTo; @ClusterScope(scope = TEST, transportClientRatio = 0, numClientNodes = 0, numDataNodes = 0) public class MonitoringPluginTests extends MonitoringIntegTestCase { + public MonitoringPluginTests() throws Exception { + super(); + } + @Override protected void startMonitoringService() { // do nothing as monitoring is sometime unbound @@ -87,6 +92,16 @@ public class MonitoringPluginTests extends MonitoringIntegTestCase { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(MonitoringService.INTERVAL.getKey(), "-1") + .put(XPackSettings.SECURITY_ENABLED.getKey(), false) + .put(XPackSettings.WATCHER_ENABLED.getKey(), false) + .build(); + } + + @Override + protected Settings transportClientSettings() { + return Settings.builder() + .put(super.transportClientSettings()) + .put(XPackSettings.SECURITY_ENABLED.getKey(), false) .build(); } @@ -130,7 +145,7 @@ public class MonitoringPluginTests extends MonitoringIntegTestCase { for (PluginInfo plugin : nodeInfo.getPlugins().getPluginInfos()) { assertNotNull(plugin); - if (XPackPlugin.class.getName().equals(plugin.getName())) { + if (LocalStateMonitoring.class.getName().equals(plugin.getName())) { found = true; break; } diff --git a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTribeTests.java b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTribeTests.java index 3af10a6812b..4babeaed06e 100644 --- a/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTribeTests.java +++ b/qa/tribe-tests-with-license/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringTribeTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.monitoring; import org.elasticsearch.client.Client; import org.elasticsearch.license.TribeTransportTestCase; +import org.elasticsearch.xpack.XPackField; import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction; import org.elasticsearch.xpack.monitoring.action.MonitoringBulkRequest; @@ -17,7 +18,7 @@ public class MonitoringTribeTests extends TribeTransportTestCase { @Override protected List enabledFeatures() { - return Collections.singletonList(Monitoring.NAME); + return Collections.singletonList(XPackField.MONITORING); } @Override diff --git a/qa/tribe-tests-with-security/build.gradle b/qa/tribe-tests-with-security/build.gradle index c8ef1299ae4..18889359e0f 100644 --- a/qa/tribe-tests-with-security/build.gradle +++ b/qa/tribe-tests-with-security/build.gradle @@ -8,8 +8,9 @@ apply plugin: 'elasticsearch.rest-test' dependencies { testCompile project(path: ':modules:tribe', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'runtime') - testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') + 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:security', configuration: 'testArtifacts') testCompile project(path: ':modules:analysis-common', configuration: 'runtime') } @@ -17,7 +18,7 @@ namingConventions.skipIntegTestInDisguise = true compileTestJava.options.compilerArgs << "-Xlint:-try" -String xpackPath = project(':x-pack-elasticsearch:plugin').projectDir.toPath().resolve('src/test/resources').toString() +String xpackPath = project(':x-pack-elasticsearch:plugin:core').projectDir.toPath().resolve('src/test/resources').toString() sourceSets { test { resources { diff --git a/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/test/TribeWithSecurityIT.java b/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/test/TribeWithSecurityIT.java index a76d2683dc8..751e7523490 100644 --- a/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/test/TribeWithSecurityIT.java +++ b/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/test/TribeWithSecurityIT.java @@ -8,6 +8,8 @@ package org.elasticsearch.test; import com.carrotsearch.hppc.cursors.ObjectCursor; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; +import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper; @@ -16,6 +18,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.elasticsearch.xpack.security.action.role.GetRolesResponse; import org.elasticsearch.xpack.security.action.role.PutRoleResponse; import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken; @@ -28,16 +31,19 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.URL; 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.stream.Collectors; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.elasticsearch.xpack.security.support.IndexLifecycleManager.INTERNAL_SECURITY_INDEX; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.arrayContaining; +import static org.hamcrest.core.IsCollectionContaining.hasItem; public class TribeWithSecurityIT extends SecurityIntegTestCase { @@ -55,6 +61,22 @@ public class TribeWithSecurityIT extends SecurityIntegTestCase { } } + /** + * TODO: this entire class should be removed. SecurityIntegTestCase is meant for tests, but we run against real xpack + */ + @Override + public void doAssertXPackIsInstalled() { + NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); + for (NodeInfo nodeInfo : nodeInfos.getNodes()) { + // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? +// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2)); + Collection pluginNames = + nodeInfo.getPlugins().getPluginInfos().stream().map(p -> p.getClassname()).collect(Collectors.toList()); + assertThat("plugin [" + Security.class.getName() + "] not found in [" + pluginNames + "]", pluginNames, + hasItem(Security.class.getName())); + } + } + @AfterClass public static void tearDownExternalClusters() throws IOException { @@ -89,7 +111,7 @@ public class TribeWithSecurityIT extends SecurityIntegTestCase { @Override protected Settings externalClusterClientSettings() { Settings.Builder builder = Settings.builder().put(super.externalClusterClientSettings()); - builder.put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME4); + builder.put(NetworkModule.TRANSPORT_TYPE_KEY, SecurityField.NAME4); return builder.build(); } diff --git a/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/xpack/security/SecurityTribeTests.java b/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/xpack/security/SecurityTribeTests.java index cdaa94c01bc..82eaeef1c52 100644 --- a/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/xpack/security/SecurityTribeTests.java +++ b/qa/tribe-tests-with-security/src/test/java/org/elasticsearch/xpack/security/SecurityTribeTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.NativeRealmIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; +import org.elasticsearch.test.SecuritySettingsSourceField; import org.elasticsearch.test.discovery.TestZenDiscovery; import org.elasticsearch.tribe.TribePlugin; import org.elasticsearch.tribe.TribeService; @@ -142,12 +143,12 @@ public class SecurityTribeTests extends NativeRealmIntegTestCase { public void tearDownTribeNodeAndWipeCluster() throws Exception { if (cluster2 != null) { try { - cluster2.wipe(Collections.singleton(SecurityLifecycleService.SECURITY_TEMPLATE_NAME)); + cluster2.wipe(Collections.singleton(SecurityLifecycleServiceField.SECURITY_TEMPLATE_NAME)); try { // this is a hack to clean up the .security index since only the XPackSecurity user or superusers can delete it final Client cluster2Client = cluster2.client().filterWithHeader(Collections.singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_SUPERUSER, - SecuritySettingsSource.TEST_PASSWORD_SECURE_STRING))); + SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING))); cluster2Client.admin().indices().prepareDelete(IndexLifecycleManager.INTERNAL_SECURITY_INDEX).get(); } catch (IndexNotFoundException e) { // ignore it since not all tests create this index... diff --git a/qa/vagrant/build.gradle b/qa/vagrant/build.gradle index 469ed87790b..5dce18ffefd 100644 --- a/qa/vagrant/build.gradle +++ b/qa/vagrant/build.gradle @@ -6,7 +6,7 @@ esvagrant { } dependencies { - bats project(path: ':x-pack-elasticsearch:plugin', configuration: 'zip') + bats project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'zip') // Inherit Bats test utils from :qa:vagrant project bats project(path: ':qa:vagrant', configuration: 'bats') diff --git a/transport-client/build.gradle b/transport-client/build.gradle index 92a786b6f31..3b21f415572 100644 --- a/transport-client/build.gradle +++ b/transport-client/build.gradle @@ -15,6 +15,8 @@ dependencies { testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testCompile "junit:junit:${versions.junit}" testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}" + + compile "org.elasticsearch.plugin:x-pack-security:${version}" } dependencyLicenses.enabled = false diff --git a/transport-client/src/main/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClient.java b/transport-client/src/main/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClient.java index 2fffd105bc7..2dd69cc721d 100644 --- a/transport-client/src/main/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClient.java +++ b/transport-client/src/main/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClient.java @@ -12,8 +12,10 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.elasticsearch.xpack.XPackClientPlugin; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import java.util.Arrays; import java.util.Collection; @@ -43,13 +45,13 @@ public class PreBuiltXPackTransportClient extends PreBuiltTransportClient { public PreBuiltXPackTransportClient(Settings settings, Collection> plugins, HostFailureListener hostFailureListener) { - super(settings, addPlugins(plugins, Collections.singletonList(XPackPlugin.class)), hostFailureListener); + super(settings, addPlugins(plugins, Collections.singletonList(XPackClientPlugin.class)), hostFailureListener); } @Override public void close() { super.close(); - if (NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(Security.NAME4)) { + if (NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(SecurityField.NAME4)) { try { GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { diff --git a/transport-client/src/test/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClientTests.java b/transport-client/src/test/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClientTests.java index 9dfd86fb306..23c4a31126f 100644 --- a/transport-client/src/test/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClientTests.java +++ b/transport-client/src/test/java/org/elasticsearch/xpack/client/PreBuiltXPackTransportClientTests.java @@ -6,11 +6,10 @@ package org.elasticsearch.xpack.client; import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.apache.lucene.util.Constants; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.xpack.security.Security; +import org.elasticsearch.xpack.security.SecurityField; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -24,7 +23,7 @@ public class PreBuiltXPackTransportClientTests extends RandomizedTest { public void testPluginInstalled() { try (TransportClient client = new PreBuiltXPackTransportClient(Settings.EMPTY)) { Settings settings = client.settings(); - assertEquals(Security.NAME4, NetworkModule.TRANSPORT_TYPE_SETTING.get(settings)); + assertEquals(SecurityField.NAME4, NetworkModule.TRANSPORT_TYPE_SETTING.get(settings)); } }