From 918d9989d36a4c3b3d8bafc69dac6abe4345e7b9 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 3 May 2022 11:18:47 -0500 Subject: [PATCH] Enforce import checkstyle/spotless rules (#1795) Signed-off-by: Peter Nied --- .github/workflows/code-hygiene.yml | 30 +++++++ build.gradle | 8 ++ config/checkstyle/sun_checks.xml | 15 +++- .../jwt/AbstractHTTPJwtAuthenticator.java | 13 +-- .../auth/http/jwt/HTTPJwtAuthenticator.java | 15 ++-- ...TTPJwtKeyByOpenIdConnectAuthenticator.java | 4 +- .../auth/http/jwt/keybyoidc/JwtVerifier.java | 7 +- .../http/jwt/keybyoidc/KeySetRetriever.java | 5 +- .../jwt/keybyoidc/SelfRefreshingKeySet.java | 5 +- .../kerberos/HTTPSpnegoAuthenticator.java | 25 +++--- .../http/saml/AuthTokenProcessorHandler.java | 30 +++---- .../auth/http/saml/HTTPSamlAuthenticator.java | 55 ++++++------- .../auth/http/saml/Saml2SettingsProvider.java | 15 ++-- .../saml/SamlFilesystemMetadataResolver.java | 6 +- .../http/saml/SamlHTTPMetadataResolver.java | 6 +- .../com/amazon/dlic/auth/ldap/LdapUser.java | 1 + .../backend/LDAPAuthenticationBackend.java | 10 +-- .../backend/LDAPAuthorizationBackend.java | 17 ++-- .../dlic/auth/ldap/util/LdapHelper.java | 3 +- .../com/amazon/dlic/auth/ldap/util/Utils.java | 7 +- .../ldap2/LDAPAuthenticationBackend2.java | 11 +-- .../auth/ldap2/LDAPAuthorizationBackend2.java | 13 +-- .../ldap2/LDAPConnectionFactoryFactory.java | 5 +- .../dlic/auth/ldap2/LDAPUserSearcher.java | 5 +- .../dlic/auth/ldap2/MakeJava9Happy.java | 4 +- .../dlic/auth/ldap2/PrivilegedProvider.java | 3 +- .../util/SettingsBasedSSLConfigurator.java | 6 +- .../security/DefaultObjectMapper.java | 8 +- .../security/NonValidatingObjectMapper.java | 6 +- .../security/OpenSearchSecurityPlugin.java | 81 ++++++++++--------- .../TransportConfigUpdateAction.java | 8 +- .../action/whoami/TransportWhoAmIAction.java | 7 +- .../action/whoami/WhoAmIRequestBuilder.java | 4 +- .../security/auditlog/AuditLog.java | 2 +- .../auditlog/AuditLogSslExceptionHandler.java | 3 +- .../security/auditlog/NullAuditLog.java | 2 +- .../security/auditlog/config/AuditConfig.java | 24 +++--- .../auditlog/config/ThreadPoolConfig.java | 2 +- .../auditlog/impl/AbstractAuditLog.java | 20 ++--- .../security/auditlog/impl/AuditCategory.java | 10 +-- .../security/auditlog/impl/AuditLogImpl.java | 6 +- .../security/auditlog/impl/AuditMessage.java | 16 ++-- .../auditlog/impl/RequestResolver.java | 8 +- .../auditlog/routing/AsyncStoragePool.java | 4 +- .../auditlog/routing/AuditMessageRouter.java | 10 +-- .../security/auditlog/sink/AuditLogSink.java | 6 +- .../security/auditlog/sink/DebugSink.java | 1 - .../auditlog/sink/ExternalOpenSearchSink.java | 2 +- .../auditlog/sink/InternalOpenSearchSink.java | 8 +- .../security/auditlog/sink/KafkaSink.java | 2 +- .../security/auditlog/sink/Log4JSink.java | 4 +- .../security/auditlog/sink/NoopSink.java | 1 - .../security/auditlog/sink/SinkProvider.java | 6 +- .../security/auditlog/sink/WebhookSink.java | 2 +- .../security/auth/AuthenticationBackend.java | 1 - .../security/auth/AuthorizationBackend.java | 1 - .../security/auth/BackendRegistry.java | 18 ++--- .../security/auth/HTTPAuthenticator.java | 1 - .../security/auth/RolesInjector.java | 13 +-- .../security/auth/UserInjector.java | 6 +- .../HeapBasedClientBlockRegistry.java | 5 +- .../InternalAuthenticationBackend.java | 4 +- .../internal/NoOpAuthenticationBackend.java | 1 - .../internal/NoOpAuthorizationBackend.java | 1 - .../auth/limiting/AbstractRateLimiter.java | 1 - .../limiting/AddressBasedRateLimiter.java | 1 - .../limiting/UserNameBasedRateLimiter.java | 1 - .../security/compliance/ComplianceConfig.java | 22 ++--- ...mplianceIndexingOperationListenerImpl.java | 4 +- .../compliance/FieldReadCallback.java | 6 +- .../security/configuration/AdminDNs.java | 7 +- .../configuration/ClusterInfoHolder.java | 3 +- .../security/configuration/CompatConfig.java | 8 +- .../configuration/ConfigCallback.java | 1 - .../ConfigurationLoaderSecurity7.java | 14 ++-- .../ConfigurationRepository.java | 18 ++--- .../DlsFilterLevelActionHandler.java | 3 +- .../configuration/DlsFlsFilterLeafReader.java | 10 +-- .../configuration/DlsFlsValveImpl.java | 11 ++- .../configuration/DlsQueryParser.java | 8 +- .../security/configuration/MaskedField.java | 3 +- .../PrivilegesInterceptorImpl.java | 9 +-- .../security/configuration/Salt.java | 13 +-- .../SecurityFlsDlsIndexSearcherWrapper.java | 9 +-- .../SecurityIndexSearcherWrapper.java | 12 +-- .../dlic/rest/api/AbstractApiAction.java | 14 ++-- .../dlic/rest/api/AccountApiAction.java | 41 +++++----- .../dlic/rest/api/ActionGroupsApiAction.java | 6 +- .../dlic/rest/api/AuditApiAction.java | 35 ++++---- .../rest/api/AuthTokenProcessorAction.java | 26 +++--- .../dlic/rest/api/FlushCacheApiAction.java | 8 +- .../dlic/rest/api/InternalUsersApiAction.java | 37 ++++----- .../dlic/rest/api/MigrateApiAction.java | 19 +++-- .../dlic/rest/api/NodesDnApiAction.java | 34 ++++---- .../rest/api/PatchableResourceApiAction.java | 18 ++--- .../dlic/rest/api/PermissionsInfoAction.java | 1 + .../rest/api/RestApiPrivilegesEvaluator.java | 3 +- .../dlic/rest/api/RolesApiAction.java | 7 +- .../dlic/rest/api/RolesMappingApiAction.java | 8 +- .../dlic/rest/api/SecurityConfigAction.java | 10 +-- .../dlic/rest/api/TenantsApiAction.java | 6 +- .../dlic/rest/api/ValidateApiAction.java | 10 +-- .../dlic/rest/api/WhitelistApiAction.java | 31 ++++--- .../security/dlic/rest/support/Utils.java | 17 ++-- .../AbstractConfigurationValidator.java | 20 ++--- .../dlic/rest/validation/AuditValidator.java | 11 +-- .../rest/validation/CredentialsValidator.java | 10 +-- .../dlic/rest/validation/RolesValidator.java | 8 +- .../security/filter/SecurityFilter.java | 20 ++--- .../security/filter/SecurityRestFilter.java | 21 +++-- .../security/http/HTTPBasicAuthenticator.java | 4 +- .../http/HTTPClientCertAuthenticator.java | 4 +- .../security/http/HTTPProxyAuthenticator.java | 6 +- .../security/http/RemoteIpDetector.java | 4 +- .../http/SecurityHttpServerTransport.java | 7 +- .../SecurityNonSslHttpServerTransport.java | 6 +- .../opensearch/security/http/XFFResolver.java | 5 +- .../proxy/HTTPExtendedProxyAuthenticator.java | 6 +- .../security/httpclient/HttpClient.java | 6 +- .../privileges/PrivilegesEvaluator.java | 19 +++-- .../PrivilegesEvaluatorResponse.java | 6 +- .../privileges/PrivilegesInterceptor.java | 5 +- .../ProtectedIndexAccessEvaluator.java | 13 +-- .../SecurityIndexAccessEvaluator.java | 6 +- .../privileges/SnapshotRestoreEvaluator.java | 8 +- .../privileges/TermsAggregationEvaluator.java | 4 +- .../resolver/IndexResolverReplacer.java | 19 +++-- .../security/rest/DashboardsInfoAction.java | 12 +-- .../rest/SecurityConfigUpdateAction.java | 15 ++-- .../security/rest/SecurityHealthAction.java | 9 +-- .../security/rest/SecurityInfoAction.java | 10 +-- .../security/rest/SecurityWhoAmIAction.java | 11 +-- .../security/rest/TenantInfoAction.java | 22 ++--- .../security/securityconf/ConfigModel.java | 1 - .../security/securityconf/ConfigModelV6.java | 17 ++-- .../security/securityconf/ConfigModelV7.java | 17 ++-- .../securityconf/DynamicConfigFactory.java | 25 +++--- .../securityconf/DynamicConfigModel.java | 4 +- .../securityconf/DynamicConfigModelV6.java | 10 +-- .../securityconf/DynamicConfigModelV7.java | 10 +-- .../security/securityconf/Migration.java | 19 +++-- .../security/securityconf/NodesDnModel.java | 4 +- .../security/securityconf/impl/NodesDn.java | 4 +- .../impl/SecurityDynamicConfiguration.java | 12 +-- .../impl/WhitelistingSettings.java | 9 ++- .../securityconf/impl/v6/ActionGroupsV6.java | 1 + .../securityconf/impl/v6/ConfigV6.java | 1 + .../securityconf/impl/v6/InternalUserV6.java | 1 + .../securityconf/impl/v6/RoleMappingsV6.java | 3 +- .../security/securityconf/impl/v6/RoleV6.java | 1 + .../securityconf/impl/v7/ActionGroupsV7.java | 1 + .../securityconf/impl/v7/ConfigV7.java | 1 + .../securityconf/impl/v7/InternalUserV7.java | 1 + .../security/securityconf/impl/v7/RoleV7.java | 1 + .../securityconf/impl/v7/TenantV7.java | 1 + .../setting/OpensearchDynamicSetting.java | 3 +- .../setting/TransportPassiveAuthSetting.java | 2 +- .../security/ssl/DefaultSecurityKeyStore.java | 35 ++++---- .../ssl/ExternalSecurityKeyStore.java | 1 - .../ssl/OpenSearchSecuritySSLPlugin.java | 29 ++++--- .../security/ssl/SecurityKeyStore.java | 3 +- .../SecuritySSLNettyHttpServerTransport.java | 12 +-- .../ssl/http/netty/ValidatingDispatcher.java | 6 +- .../ssl/rest/SecuritySSLCertsInfoAction.java | 28 +++---- .../ssl/rest/SecuritySSLInfoAction.java | 7 +- .../rest/SecuritySSLReloadCertsAction.java | 16 ++-- .../transport/DefaultPrincipalExtractor.java | 3 +- .../ssl/transport/DualModeSSLHandler.java | 16 ++-- .../security/ssl/transport/SSLConfig.java | 6 +- .../transport/SecuritySSLNettyTransport.java | 29 ++++--- .../transport/SecuritySSLRequestHandler.java | 17 ++-- .../SecuritySSLTransportInterceptor.java | 6 +- .../security/ssl/util/CertFromFile.java | 4 +- .../security/ssl/util/CertFromKeystore.java | 7 +- .../security/ssl/util/CertFromTruststore.java | 4 +- .../ssl/util/SSLCertificateHelper.java | 3 +- .../ssl/util/SSLConnectionTestUtil.java | 5 +- .../security/ssl/util/SSLRequestHelper.java | 7 +- .../opensearch/security/ssl/util/TLSUtil.java | 4 +- .../security/support/Base64Helper.java | 23 +++--- .../security/support/ConfigConstants.java | 7 +- .../security/support/ConfigHelper.java | 8 +- .../security/support/HTTPHelper.java | 2 +- .../security/support/HeaderHelper.java | 4 +- .../security/support/PemKeyReader.java | 3 +- .../security/support/ReflectionHelper.java | 4 +- .../security/support/SecurityJsonNode.java | 1 + .../security/support/SecurityUtils.java | 4 +- .../support/SnapshotRestoreHelper.java | 5 +- .../security/tools/AuditConfigMigrater.java | 17 ++-- .../opensearch/security/tools/Migrater.java | 8 +- .../security/tools/SecurityAdmin.java | 63 ++++++++------- .../DefaultInterClusterRequestEvaluator.java | 12 +-- .../transport/OIDClusterRequestEvaluator.java | 3 +- .../transport/SecurityInterceptor.java | 26 +++--- .../transport/SecurityRequestHandler.java | 23 +++--- .../org/opensearch/security/user/User.java | 4 +- .../ratetracking/HeapBasedRateTracker.java | 5 +- .../http/jwt/HTTPJwtAuthenticatorTest.java | 13 ++- ...wtKeyByOpenIdConnectAuthenticatorTest.java | 4 +- .../jwt/keybyoidc/KeySetRetrieverTest.java | 3 +- .../http/jwt/keybyoidc/MockIpdServer.java | 4 +- .../keybyoidc/SelfRefreshingKeySetTest.java | 5 -- ...wtKeyByOpenIdConnectAuthenticatorTest.java | 4 +- .../auth/http/jwt/keybyoidc/TestJwts.java | 3 +- .../http/saml/HTTPSamlAuthenticatorTest.java | 21 +++-- .../auth/http/saml/MockSamlIdpServer.java | 5 +- .../dlic/auth/ldap/LdapBackendIntegTest.java | 5 +- .../dlic/auth/ldap/LdapBackendTest.java | 5 +- .../auth/ldap/LdapBackendTestClientCert.java | 3 +- .../ldap/LdapBackendTestNewStyleConfig.java | 5 +- .../com/amazon/dlic/auth/ldap/UtilsTest.java | 2 - .../amazon/dlic/auth/ldap/srv/LdapServer.java | 11 +-- .../auth/ldap2/LdapBackendIntegTest2.java | 5 +- .../ldap2/LdapBackendTestClientCert2.java | 3 +- .../ldap2/LdapBackendTestNewStyleConfig2.java | 11 ++- .../ldap2/LdapBackendTestOldStyleConfig2.java | 11 ++- .../AdvancedSecurityMigrationTests.java | 15 ++-- .../opensearch/security/AggregationTests.java | 6 +- .../org/opensearch/security/ConfigTests.java | 10 +-- .../security/DataStreamIntegrationTests.java | 1 + .../EncryptionInTransitMigrationTests.java | 9 ++- .../org/opensearch/security/HealthTests.java | 4 +- .../security/HttpIntegrationTests.java | 12 ++- .../security/IndexIntegrationTests.java | 15 ++-- .../InitializationIntegrationTests.java | 8 +- .../opensearch/security/IntegrationTests.java | 16 ++-- .../security/PrivilegesEvaluationTest.java | 4 +- .../opensearch/security/ResolveAPITests.java | 5 +- .../security/RolesInjectorIntegTest.java | 21 ++--- .../security/RolesValidationIntegTest.java | 11 +-- .../SecurityAdminIEndpointsTests.java | 1 + .../SecurityAdminInvalidConfigsTests.java | 4 +- .../security/SecurityAdminTests.java | 6 +- .../security/SecurityRolesTests.java | 4 +- .../security/SlowIntegrationTests.java | 10 ++- .../security/SnapshotRestoreTests.java | 14 ++-- .../security/SystemIntegratorsTests.java | 6 +- .../org/opensearch/security/TaskTests.java | 7 +- .../org/opensearch/security/TracingTests.java | 8 +- .../TransportUserInjectorIntegTest.java | 21 ++--- .../org/opensearch/security/UtilTests.java | 14 ++-- .../auditlog/AbstractAuditlogiUnitTest.java | 8 +- .../security/auditlog/AuditTestUtils.java | 13 +-- .../compliance/ComplianceAuditlogTest.java | 29 ++++--- .../compliance/ComplianceConfigTest.java | 14 ++-- .../RestApiComplianceAuditlogTest.java | 4 +- .../config/AuditConfigFilterTest.java | 24 +++--- .../config/AuditConfigSerializeTest.java | 30 +++---- .../auditlog/config/ThreadPoolConfigTest.java | 3 +- .../security/auditlog/helper/FailingSink.java | 1 - .../security/auditlog/helper/LoggingSink.java | 1 - .../helper/MockAuditMessageFactory.java | 11 ++- .../security/auditlog/helper/RetrySink.java | 1 - .../security/auditlog/helper/SlowSink.java | 1 - .../auditlog/impl/AuditCategoryTest.java | 12 +-- .../auditlog/impl/AuditMessageTest.java | 19 ++--- .../security/auditlog/impl/AuditlogTest.java | 14 ++-- .../security/auditlog/impl/DelegateTest.java | 4 +- .../auditlog/impl/DisabledCategoriesTest.java | 25 +++--- .../auditlog/impl/IgnoreAuditUsersTest.java | 17 ++-- .../security/auditlog/impl/TracingTests.java | 14 ++-- .../integration/BasicAuditlogTest.java | 33 +++----- .../auditlog/integration/SSLAuditlogTest.java | 4 +- .../integration/TestAuditlogImpl.java | 1 - .../auditlog/routing/FallbackTest.java | 4 +- .../security/auditlog/routing/PerfTest.java | 4 +- .../security/auditlog/routing/RouterTest.java | 4 +- .../routing/RoutingConfigurationTest.java | 4 +- .../security/auditlog/sink/KafkaSinkTest.java | 11 ++- .../auditlog/sink/SinkProviderTLSTest.java | 6 +- .../auditlog/sink/SinkProviderTest.java | 2 +- .../auditlog/sink/WebhookAuditLogTest.java | 6 +- .../security/auth/RolesInjectorTest.java | 17 ++-- .../security/auth/UserInjectorTest.java | 17 ++-- .../HeapBasedClientBlockRegistryTest.java | 4 +- .../limiting/AddressBasedRateLimiterTest.java | 8 +- .../limiting/HeapBasedRateTrackerTest.java | 6 +- .../UserNameBasedRateLimiterTest.java | 9 ++- .../security/cache/CachingTest.java | 4 +- .../cache/DummyAuthenticationBackend.java | 1 - .../security/cache/DummyAuthorizer.java | 1 - .../cache/DummyHTTPAuthenticator.java | 1 - .../ccstest/CrossClusterSearchTests.java | 38 ++++----- .../security/ccstest/RemoteReindexTests.java | 14 ++-- .../security/configuration/SaltTest.java | 11 +-- .../dlic/dlsfls/AbstractDlsFlsTest.java | 3 +- .../dlic/dlsfls/CCReplicationTest.java | 10 +-- .../CustomFieldMaskedComplexMappingTest.java | 6 +- .../dlic/dlsfls/CustomFieldMaskedTest.java | 6 +- .../security/dlic/dlsfls/DateMathTest.java | 6 +- .../dlic/dlsfls/DfmOverwritesAllTest.java | 1 + .../security/dlic/dlsfls/DlsDateMathTest.java | 6 +- .../dlsfls/DlsFlsCrossClusterSearchTest.java | 10 +-- .../security/dlic/dlsfls/DlsNestedTest.java | 6 +- .../dlic/dlsfls/DlsPropsReplaceTest.java | 6 +- .../security/dlic/dlsfls/DlsScrollTest.java | 6 +- .../dlic/dlsfls/DlsTermLookupQueryTest.java | 5 +- .../dlic/dlsfls/DlsTermsLookupAsserts.java | 5 +- .../security/dlic/dlsfls/DlsTest.java | 7 +- .../security/dlic/dlsfls/FieldMaskedTest.java | 6 +- .../security/dlic/dlsfls/Fls983Test.java | 6 +- .../security/dlic/dlsfls/FlsDlsTestAB.java | 6 +- .../dlic/dlsfls/FlsDlsTestForbiddenField.java | 6 +- .../security/dlic/dlsfls/FlsDlsTestMulti.java | 6 +- .../dlic/dlsfls/FlsExistsFieldsTest.java | 6 +- .../security/dlic/dlsfls/FlsFieldsTest.java | 6 +- .../security/dlic/dlsfls/FlsFieldsWcTest.java | 6 +- .../security/dlic/dlsfls/FlsPerfTest.java | 8 +- .../security/dlic/dlsfls/FlsTest.java | 6 +- .../dlic/dlsfls/IndexPatternTest.java | 6 +- .../security/dlic/dlsfls/MFlsTest.java | 6 +- .../rest/api/AbstractRestApiUnitTest.java | 14 ++-- .../dlic/rest/api/AccountApiTest.java | 17 ++-- .../dlic/rest/api/ActionGroupsApiTest.java | 9 ++- .../dlic/rest/api/AuditApiActionTest.java | 33 ++++---- .../rest/api/DashboardsInfoActionTest.java | 7 +- .../dlic/rest/api/FlushCacheApiTest.java | 7 +- .../rest/api/GetConfigurationApiTest.java | 10 +-- .../dlic/rest/api/IndexMissingTest.java | 4 +- .../dlic/rest/api/NodesDnApiTest.java | 31 +++---- .../api/RestApiPrivilegesEvaluatorTest.java | 15 ++-- .../dlic/rest/api/RoleBasedAccessTest.java | 8 +- .../security/dlic/rest/api/RolesApiTest.java | 14 ++-- .../dlic/rest/api/RolesMappingApiTest.java | 6 +- .../dlic/rest/api/SecurityApiAccessTest.java | 2 +- .../dlic/rest/api/SecurityConfigApiTest.java | 4 +- .../rest/api/SecurityHealthActionTest.java | 9 ++- .../dlic/rest/api/SecurityInfoActionTest.java | 7 +- .../dlic/rest/api/TenantInfoActionTest.java | 7 +- .../security/dlic/rest/api/UserApiTest.java | 21 ++--- .../dlic/rest/api/WhitelistApiTest.java | 28 +++---- .../security/filter/SecurityFilterTest.java | 34 ++++---- .../filter/SecurityRestFilterTest.java | 7 +- .../HTTPExtendedProxyAuthenticatorTest.java | 18 ++--- .../security/httpclient/HttpClientTest.java | 2 +- .../multitenancy/test/MultitenancyTests.java | 6 +- .../privileges/PrivilegesEvaluatorTest.java | 1 + .../ProtectedIndicesTests.java | 13 +-- .../securityconf/impl/v6/ConfigV6Test.java | 3 +- .../securityconf/impl/v7/ConfigV7Test.java | 3 +- .../ssl/CertificateValidatorTest.java | 4 +- .../opensearch/security/ssl/OpenSSLTest.java | 18 ++--- .../org/opensearch/security/ssl/SSLTest.java | 22 +++-- .../ssl/SecuritySSLCertsInfoActionTests.java | 17 ++-- .../SecuritySSLReloadCertsActionTests.java | 23 +++--- .../transport/DualModeSSLHandlerTests.java | 12 +-- .../security/ssl/util/CertFromFileTests.java | 4 +- .../ssl/util/CertFromKeystoreTests.java | 4 +- .../ssl/util/CertFromTruststoreTests.java | 4 +- .../ssl/util/SSLConnectionTestUtilTests.java | 1 + .../security/support/Base64HelperTest.java | 14 ++-- .../system_indices/SystemIndicesTests.java | 23 +++--- .../test/AbstractSecurityUnitTest.java | 63 ++++++--------- .../security/test/DynamicSecurityConfig.java | 1 - .../security/test/SingleClusterTest.java | 8 +- .../helper/cluster/ClusterConfiguration.java | 8 +- .../test/helper/cluster/ClusterHelper.java | 8 +- .../security/test/helper/file/FileHelper.java | 3 +- .../security/test/helper/rest/RestHelper.java | 2 +- .../test/plugin/UserInjectorPlugin.java | 4 +- .../SettingsBasedSSLConfiguratorTest.java | 9 ++- 362 files changed, 1825 insertions(+), 1773 deletions(-) diff --git a/.github/workflows/code-hygiene.yml b/.github/workflows/code-hygiene.yml index 1952630e5b..6691ee8a15 100644 --- a/.github/workflows/code-hygiene.yml +++ b/.github/workflows/code-hygiene.yml @@ -12,3 +12,33 @@ jobs: - name: Linelint uses: fernandrone/linelint@0.0.4 + + spotless: + runs-on: ubuntu-latest + name: Spotless scan + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v2 + with: + distribution: temurin # Temurin is a distribution of adoptium + java-version: 11 + + - uses: gradle/gradle-build-action@v2 + with: + arguments: spotlessCheck + + checkstyle: + runs-on: ubuntu-latest + name: Checkstyle scan + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v2 + with: + distribution: temurin # Temurin is a distribution of adoptium + java-version: 11 + + - uses: gradle/gradle-build-action@v2 + with: + arguments: checkstyleMain checkstyleTest diff --git a/build.gradle b/build.gradle index 90ca3e49ce..c7054ca94c 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,7 @@ plugins { id "nebula.ospackage" version "9.0.0" id "com.google.osdetector" version "1.7.0" id "org.gradle.test-retry" version "1.3.1" + id "com.diffplug.spotless" version "6.5.0" } import org.gradle.crypto.checksum.Checksum @@ -378,6 +379,13 @@ tasks.withType(Checkstyle) { } } +spotless { + java { + // note: you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports + importOrder('java', 'javax', '', 'com.amazon', 'org.opensearch', '\\#') + } +} + buildRpm { arch = 'NOARCH' addParentDirs = false diff --git a/config/checkstyle/sun_checks.xml b/config/checkstyle/sun_checks.xml index be1008ff85..8dbbedefcd 100644 --- a/config/checkstyle/sun_checks.xml +++ b/config/checkstyle/sun_checks.xml @@ -108,11 +108,18 @@ - - - + + + + + + + + + - + + diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java index 06dd89ef35..a75810c83d 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java @@ -26,8 +26,14 @@ import org.apache.cxf.rs.security.jose.jwt.JwtClaims; import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.http.HttpHeaders; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; +import com.amazon.dlic.auth.http.jwt.keybyoidc.BadCredentialsException; +import com.amazon.dlic.auth.http.jwt.keybyoidc.JwtVerifier; +import com.amazon.dlic.auth.http.jwt.keybyoidc.KeyProvider; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.Strings; @@ -37,11 +43,6 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; - -import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; -import com.amazon.dlic.auth.http.jwt.keybyoidc.BadCredentialsException; -import com.amazon.dlic.auth.http.jwt.keybyoidc.JwtVerifier; -import com.amazon.dlic.auth.http.jwt.keybyoidc.KeyProvider; import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticator.java index b417df047c..0b827bab76 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticator.java @@ -28,9 +28,15 @@ import java.util.Map.Entry; import java.util.regex.Pattern; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtParser; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.io.Decoders; +import io.jsonwebtoken.security.WeakKeyException; import org.apache.http.HttpHeaders; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -39,16 +45,9 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; - import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.user.AuthCredentials; -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtParser; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.io.Decoders; -import io.jsonwebtoken.security.WeakKeyException; - public class HTTPJwtAuthenticator implements HTTPAuthenticator { protected final Logger log = LogManager.getLogger(this.getClass()); diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java index 8c3c0ff18d..889abb4b2c 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java @@ -17,11 +17,11 @@ import java.nio.file.Path; -import org.opensearch.common.settings.Settings; - import com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator; import com.amazon.dlic.util.SettingsBasedSSLConfigurator; +import org.opensearch.common.settings.Settings; + public class HTTPJwtKeyByOpenIdConnectAuthenticator extends AbstractHTTPJwtAuthenticator { //private final static Logger log = LogManager.getLogger(HTTPJwtKeyByOpenIdConnectAuthenticator.class); diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/JwtVerifier.java b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/JwtVerifier.java index 112118f3a6..18da40c772 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/JwtVerifier.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/JwtVerifier.java @@ -15,6 +15,8 @@ package com.amazon.dlic.auth.http.jwt.keybyoidc; +import com.google.common.base.Strings; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; import org.apache.cxf.rs.security.jose.jwk.KeyType; @@ -26,11 +28,8 @@ import org.apache.cxf.rs.security.jose.jwt.JwtException; import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.cxf.rs.security.jose.jwt.JwtUtils; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; - -import com.google.common.base.Strings; +import org.apache.logging.log4j.Logger; public class JwtVerifier { diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetriever.java b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetriever.java index eb75536886..a2c77c1277 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetriever.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetriever.java @@ -17,7 +17,6 @@ import java.io.IOException; -import org.opensearch.security.DefaultObjectMapper; import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys; import org.apache.cxf.rs.security.jose.jwk.JwkUtils; import org.apache.http.HttpEntity; @@ -33,12 +32,14 @@ import org.apache.http.impl.client.cache.BasicHttpCacheStorage; import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClients; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.amazon.dlic.auth.http.jwt.oidc.json.OpenIdProviderConfiguration; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfig; +import org.opensearch.security.DefaultObjectMapper; + public class KeySetRetriever implements KeySetProvider { private final static Logger log = LogManager.getLogger(KeySetRetriever.class); diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySet.java b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySet.java index da0e179e19..45a77acd6a 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySet.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySet.java @@ -22,12 +22,11 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import com.google.common.base.Strings; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; - -import com.google.common.base.Strings; +import org.apache.logging.log4j.Logger; public class SelfRefreshingKeySet implements KeyProvider { private static final Logger log = LogManager.getLogger(SelfRefreshingKeySet.class); diff --git a/src/main/java/com/amazon/dlic/auth/http/kerberos/HTTPSpnegoAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/kerberos/HTTPSpnegoAuthenticator.java index 10634a626a..8e4bae67f3 100644 --- a/src/main/java/com/amazon/dlic/auth/http/kerberos/HTTPSpnegoAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/kerberos/HTTPSpnegoAuthenticator.java @@ -29,12 +29,22 @@ import java.util.HashSet; import java.util.Set; - import javax.security.auth.Subject; import javax.security.auth.login.LoginException; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.ietf.jgss.GSSContext; +import org.ietf.jgss.GSSCredential; +import org.ietf.jgss.GSSException; +import org.ietf.jgss.GSSManager; +import org.ietf.jgss.GSSName; +import org.ietf.jgss.Oid; + +import com.amazon.dlic.auth.http.kerberos.util.JaasKrbUtil; +import com.amazon.dlic.auth.http.kerberos.util.KrbConstants; + import org.opensearch.ExceptionsHelper; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -42,23 +52,12 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.env.Environment; -//import org.opensearch.env.Environment; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; -import org.ietf.jgss.GSSContext; -import org.ietf.jgss.GSSCredential; -import org.ietf.jgss.GSSException; -import org.ietf.jgss.GSSManager; -import org.ietf.jgss.GSSName; -import org.ietf.jgss.Oid; - -import com.amazon.dlic.auth.http.kerberos.util.JaasKrbUtil; -import com.amazon.dlic.auth.http.kerberos.util.KrbConstants; import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.user.AuthCredentials; -import com.google.common.base.Strings; public class HTTPSpnegoAuthenticator implements HTTPAuthenticator { diff --git a/src/main/java/com/amazon/dlic/auth/http/saml/AuthTokenProcessorHandler.java b/src/main/java/com/amazon/dlic/auth/http/saml/AuthTokenProcessorHandler.java index 25c547e4e2..54d909d959 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/AuthTokenProcessorHandler.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/AuthTokenProcessorHandler.java @@ -29,7 +29,16 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathExpressionException; -import org.opensearch.security.DefaultObjectMapper; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Strings; +import com.onelogin.saml2.authn.SamlResponse; +import com.onelogin.saml2.exception.SettingsException; +import com.onelogin.saml2.exception.ValidationError; +import com.onelogin.saml2.settings.Saml2Settings; +import com.onelogin.saml2.util.Util; import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; @@ -40,8 +49,11 @@ import org.apache.cxf.rs.security.jose.jwt.JwtClaims; import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.cxf.rs.security.jose.jwt.JwtUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.joda.time.DateTime; +import org.xml.sax.SAXException; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.bytes.BytesReference; @@ -52,20 +64,8 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; -import org.joda.time.DateTime; -import org.xml.sax.SAXException; - +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.api.AuthTokenProcessorAction; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.base.Strings; -import com.onelogin.saml2.authn.SamlResponse; -import com.onelogin.saml2.exception.SettingsException; -import com.onelogin.saml2.exception.ValidationError; -import com.onelogin.saml2.settings.Saml2Settings; -import com.onelogin.saml2.util.Util; class AuthTokenProcessorHandler { private static final Logger log = LogManager.getLogger(AuthTokenProcessorHandler.class); diff --git a/src/main/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticator.java index 774c31e465..d26ad879c3 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticator.java @@ -15,58 +15,59 @@ package com.amazon.dlic.auth.http.saml; +import java.io.IOException; import java.net.URL; import java.nio.file.Path; import java.security.AccessController; import java.security.PrivateKey; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.xml.parsers.ParserConfigurationException; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; +import com.onelogin.saml2.authn.AuthnRequest; +import com.onelogin.saml2.logout.LogoutRequest; +import com.onelogin.saml2.settings.Saml2Settings; +import com.onelogin.saml2.util.Constants; +import com.onelogin.saml2.util.Util; +import net.shibboleth.utilities.java.support.component.ComponentInitializationException; +import net.shibboleth.utilities.java.support.component.DestructableComponent; import net.shibboleth.utilities.java.support.xml.BasicParserPool; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.rest.BytesRestResponse; -import org.opensearch.rest.RestChannel; -import org.opensearch.rest.RestRequest; -import org.opensearch.rest.RestStatus; +import org.apache.logging.log4j.Logger; import org.opensaml.core.config.InitializationException; import org.opensaml.core.config.InitializationService; import org.opensaml.saml.metadata.resolver.MetadataResolver; +import org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver; +import org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; import com.amazon.dlic.auth.http.jwt.AbstractHTTPJwtAuthenticator; import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; import com.amazon.dlic.auth.http.jwt.keybyoidc.BadCredentialsException; import com.amazon.dlic.auth.http.jwt.keybyoidc.KeyProvider; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.rest.BytesRestResponse; +import org.opensearch.rest.RestChannel; +import org.opensearch.rest.RestRequest; +import org.opensearch.rest.RestStatus; import org.opensearch.security.auth.Destroyable; import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.PemKeyReader; import org.opensearch.security.user.AuthCredentials; -import com.google.common.base.Strings; -import com.onelogin.saml2.authn.AuthnRequest; -import com.onelogin.saml2.logout.LogoutRequest; -import com.onelogin.saml2.settings.Saml2Settings; -import com.onelogin.saml2.util.Constants; -import com.onelogin.saml2.util.Util; - -import net.shibboleth.utilities.java.support.component.ComponentInitializationException; -import net.shibboleth.utilities.java.support.component.DestructableComponent; -import org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver; -import org.opensaml.saml.metadata.resolver.impl.DOMMetadataResolver; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java b/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java index f29ea2abb0..d4d250ed56 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java @@ -26,11 +26,12 @@ import java.util.Set; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import com.onelogin.saml2.settings.Saml2Settings; +import com.onelogin.saml2.settings.SettingsBuilder; +import net.shibboleth.utilities.java.support.resolver.CriteriaSet; +import net.shibboleth.utilities.java.support.resolver.ResolverException; import org.apache.logging.log4j.LogManager; - -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.opensaml.core.criterion.EntityIdCriterion; import org.opensaml.saml.metadata.resolver.MetadataResolver; @@ -45,11 +46,9 @@ import org.opensaml.xmlsec.signature.X509Data; import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; -import com.onelogin.saml2.settings.Saml2Settings; -import com.onelogin.saml2.settings.SettingsBuilder; -import net.shibboleth.utilities.java.support.resolver.CriteriaSet; -import net.shibboleth.utilities.java.support.resolver.ResolverException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; public class Saml2SettingsProvider { protected final static Logger log = LogManager.getLogger(Saml2SettingsProvider.class); diff --git a/src/main/java/com/amazon/dlic/auth/http/saml/SamlFilesystemMetadataResolver.java b/src/main/java/com/amazon/dlic/auth/http/saml/SamlFilesystemMetadataResolver.java index 4ce21bc67d..40984bd058 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/SamlFilesystemMetadataResolver.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/SamlFilesystemMetadataResolver.java @@ -21,11 +21,11 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import org.opensearch.common.settings.Settings; -import org.opensearch.env.Environment; +import net.shibboleth.utilities.java.support.resolver.ResolverException; import org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver; -import net.shibboleth.utilities.java.support.resolver.ResolverException; +import org.opensearch.common.settings.Settings; +import org.opensearch.env.Environment; public class SamlFilesystemMetadataResolver extends FilesystemMetadataResolver { diff --git a/src/main/java/com/amazon/dlic/auth/http/saml/SamlHTTPMetadataResolver.java b/src/main/java/com/amazon/dlic/auth/http/saml/SamlHTTPMetadataResolver.java index 6db7f6e82a..26588d9a7f 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/SamlHTTPMetadataResolver.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/SamlHTTPMetadataResolver.java @@ -20,16 +20,16 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import net.shibboleth.utilities.java.support.resolver.ResolverException; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; import org.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver; import com.amazon.dlic.util.SettingsBasedSSLConfigurator; -import net.shibboleth.utilities.java.support.resolver.ResolverException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; public class SamlHTTPMetadataResolver extends HTTPMetadataResolver { diff --git a/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java b/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java index d6f75e4bac..12b25b7598 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java @@ -23,6 +23,7 @@ import org.ldaptive.LdapEntry; import com.amazon.dlic.auth.ldap.util.Utils; + import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java index a22ee68e8d..7aa4b3f327 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java @@ -27,11 +27,8 @@ import java.util.UUID; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.common.settings.Settings; - +import org.apache.logging.log4j.Logger; import org.ldaptive.Connection; import org.ldaptive.ConnectionConfig; import org.ldaptive.LdapEntry; @@ -42,10 +39,13 @@ import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; import com.amazon.dlic.auth.ldap.util.Utils; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.AuthenticationBackend; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import org.opensearch.security.support.WildcardMatcher; public class LDAPAuthenticationBackend implements AuthenticationBackend { diff --git a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java index b16735735d..32e0b67965 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java @@ -43,12 +43,10 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.HashMultimap; +import io.netty.util.internal.PlatformDependent; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.Strings; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.BindConnectionInitializer; import org.ldaptive.BindRequest; import org.ldaptive.Connection; @@ -63,7 +61,6 @@ import org.ldaptive.SearchScope; import org.ldaptive.control.RequestControl; import org.ldaptive.provider.ProviderConnection; -import org.ldaptive.provider.jndi.JndiConnection; import org.ldaptive.sasl.Mechanism; import org.ldaptive.sasl.SaslConfig; import org.ldaptive.ssl.AllowAnyHostnameVerifier; @@ -77,15 +74,17 @@ import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; import com.amazon.dlic.auth.ldap.util.Utils; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.Strings; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.AuthorizationBackend; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.PemKeyReader; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import com.google.common.collect.HashMultimap; - -import io.netty.util.internal.PlatformDependent; public class LDAPAuthorizationBackend implements AuthorizationBackend { diff --git a/src/main/java/com/amazon/dlic/auth/ldap/util/LdapHelper.java b/src/main/java/com/amazon/dlic/auth/ldap/util/LdapHelper.java index e79745b793..a525e5d863 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap/util/LdapHelper.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/util/LdapHelper.java @@ -25,7 +25,6 @@ import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.opensearch.SpecialPermission; import org.ldaptive.Connection; import org.ldaptive.DerefAliases; import org.ldaptive.LdapEntry; @@ -39,6 +38,8 @@ import org.ldaptive.SearchScope; import org.ldaptive.referral.SearchReferralHandler; +import org.opensearch.SpecialPermission; + public class LdapHelper { private static SearchFilter ALL = new SearchFilter("(objectClass=*)"); diff --git a/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java b/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java index d41b16cc7e..72f39dcccf 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java @@ -25,13 +25,14 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.Connection; import org.ldaptive.LdapAttribute; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; + public final class Utils { private static final Logger log = LogManager.getLogger(Utils.class); diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java index b3347daa6e..3255537219 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java @@ -25,11 +25,8 @@ import java.util.Collections; import java.util.UUID; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.BindRequest; import org.ldaptive.Connection; import org.ldaptive.ConnectionFactory; @@ -43,11 +40,15 @@ import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.Utils; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.AuthenticationBackend; import org.opensearch.security.auth.Destroyable; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import org.opensearch.security.support.WildcardMatcher; public class LDAPAuthenticationBackend2 implements AuthenticationBackend, Destroyable { diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java index 42638b741f..118848460b 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java @@ -31,12 +31,9 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.HashMultimap; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.Strings; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.Connection; import org.ldaptive.ConnectionFactory; import org.ldaptive.LdapAttribute; @@ -51,12 +48,16 @@ import com.amazon.dlic.auth.ldap.util.LdapHelper; import com.amazon.dlic.auth.ldap.util.Utils; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.Strings; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.AuthorizationBackend; import org.opensearch.security.auth.Destroyable; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import com.google.common.collect.HashMultimap; public class LDAPAuthorizationBackend2 implements AuthorizationBackend, Destroyable { diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java index 7c9e5996bc..083dca9583 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java @@ -22,9 +22,8 @@ import java.util.List; import java.util.Map; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.ActivePassiveConnectionStrategy; import org.ldaptive.BindConnectionInitializer; import org.ldaptive.CompareRequest; @@ -65,6 +64,8 @@ import com.amazon.dlic.util.SettingsBasedSSLConfigurator; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; +import org.opensearch.common.settings.Settings; + public class LDAPConnectionFactoryFactory { private static final Logger log = LogManager.getLogger(LDAPConnectionFactoryFactory.class); diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java index ccbc6ac7ae..7cbc88e953 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java @@ -23,9 +23,8 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.ldaptive.Connection; import org.ldaptive.LdapEntry; import org.ldaptive.SearchFilter; @@ -35,6 +34,8 @@ import com.amazon.dlic.auth.ldap.util.LdapHelper; import com.amazon.dlic.auth.ldap.util.Utils; +import org.opensearch.common.settings.Settings; + public class LDAPUserSearcher { protected static final Logger log = LogManager.getLogger(LDAPUserSearcher.class); diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java b/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java index ea819b18ee..3f6e77ec07 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java @@ -19,10 +19,10 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import org.opensearch.SpecialPermission; +import io.netty.util.internal.PlatformDependent; import org.ldaptive.ssl.ThreadLocalTLSSocketFactory; -import io.netty.util.internal.PlatformDependent; +import org.opensearch.SpecialPermission; public class MakeJava9Happy { diff --git a/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java b/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java index e5531d0877..a0650e6f2d 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java @@ -19,7 +19,6 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import org.opensearch.SpecialPermission; import org.ldaptive.AddRequest; import org.ldaptive.BindRequest; import org.ldaptive.CompareRequest; @@ -40,6 +39,8 @@ import org.ldaptive.provider.SearchListener; import org.ldaptive.provider.jndi.JndiProviderConfig; +import org.opensearch.SpecialPermission; + public class PrivilegedProvider implements Provider { private final Provider delegate; diff --git a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java index 1595a965d5..edf210777a 100644 --- a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java +++ b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java @@ -37,6 +37,7 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import com.google.common.collect.ImmutableList; import org.apache.http.conn.ssl.DefaultHostnameVerifier; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; @@ -45,13 +46,12 @@ import org.apache.http.ssl.PrivateKeyStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.PemKeyReader; -import com.google.common.collect.ImmutableList; public class SettingsBasedSSLConfigurator { private static final Logger log = LogManager.getLogger(SettingsBasedSSLConfigurator.class); diff --git a/src/main/java/org/opensearch/security/DefaultObjectMapper.java b/src/main/java/org/opensearch/security/DefaultObjectMapper.java index 1a95c4b8b0..daf3331955 100644 --- a/src/main/java/org/opensearch/security/DefaultObjectMapper.java +++ b/src/main/java/org/opensearch/security/DefaultObjectMapper.java @@ -37,10 +37,6 @@ import java.util.Map; import java.util.Set; -import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; -import com.google.common.collect.ImmutableSet; -import org.opensearch.SpecialPermission; - import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -51,8 +47,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; +import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.google.common.collect.ImmutableSet; + +import org.opensearch.SpecialPermission; public class DefaultObjectMapper { public static final ObjectMapper objectMapper = new ObjectMapper(); diff --git a/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java b/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java index 19bf8cf92a..06da407c80 100644 --- a/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java +++ b/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java @@ -35,16 +35,16 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import com.fasterxml.jackson.databind.InjectableValues; -import org.opensearch.SpecialPermission; - import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; +import org.opensearch.SpecialPermission; + public class NonValidatingObjectMapper { private static final ObjectMapper nonValidatingObjectMapper = new ObjectMapper(); diff --git a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java index c22a950738..2ba04baec2 100644 --- a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java +++ b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java @@ -39,7 +39,15 @@ import java.security.MessageDigest; import java.security.PrivilegedAction; import java.security.Security; -import java.util.*; +import java.util.ArrayList; +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.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -47,31 +55,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.opensearch.security.auditlog.NullAuditLog; -import org.opensearch.security.auditlog.impl.AuditLogImpl; -import org.opensearch.security.compliance.ComplianceIndexingOperationListenerImpl; -import org.opensearch.security.configuration.DlsFlsValveImpl; -import org.opensearch.security.configuration.SecurityFlsDlsIndexSearcherWrapper; -import org.opensearch.security.configuration.PrivilegesInterceptorImpl; -import org.opensearch.security.configuration.Salt; -import org.opensearch.security.dlic.rest.api.SecurityRestApiActions; -import org.opensearch.security.filter.SecurityRestFilter; -import org.opensearch.security.http.SecurityHttpServerTransport; -import org.opensearch.security.rest.SecurityConfigUpdateAction; -import org.opensearch.security.rest.SecurityWhoAmIAction; -import org.opensearch.security.ssl.OpenSearchSecuritySSLPlugin; -import org.opensearch.security.ssl.rest.SecuritySSLReloadCertsAction; -import org.opensearch.security.ssl.rest.SecuritySSLCertsInfoAction; -import org.opensearch.security.ssl.transport.DefaultPrincipalExtractor; -import org.opensearch.security.transport.SecurityInterceptor; -import org.opensearch.security.setting.OpensearchDynamicSetting; -import org.opensearch.security.setting.TransportPassiveAuthSetting; - -import org.apache.logging.log4j.Logger; +import com.google.common.collect.Lists; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.search.QueryCachingPolicy; import org.apache.lucene.search.Weight; import org.bouncycastle.jce.provider.BouncyCastleProvider; + import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; @@ -131,24 +121,56 @@ import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; import org.opensearch.security.auditlog.AuditLogSslExceptionHandler; +import org.opensearch.security.auditlog.NullAuditLog; +import org.opensearch.security.auditlog.impl.AuditLogImpl; import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.compliance.ComplianceIndexingOperationListener; +import org.opensearch.security.compliance.ComplianceIndexingOperationListenerImpl; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ClusterInfoHolder; +import org.opensearch.security.configuration.CompatConfig; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.configuration.DlsFlsRequestValve; +import org.opensearch.security.configuration.DlsFlsValveImpl; +import org.opensearch.security.configuration.PrivilegesInterceptorImpl; +import org.opensearch.security.configuration.Salt; +import org.opensearch.security.configuration.SecurityFlsDlsIndexSearcherWrapper; +import org.opensearch.security.dlic.rest.api.SecurityRestApiActions; import org.opensearch.security.filter.SecurityFilter; +import org.opensearch.security.filter.SecurityRestFilter; +import org.opensearch.security.http.SecurityHttpServerTransport; import org.opensearch.security.http.SecurityNonSslHttpServerTransport; import org.opensearch.security.http.XFFResolver; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.privileges.PrivilegesInterceptor; import org.opensearch.security.resolver.IndexResolverReplacer; import org.opensearch.security.rest.DashboardsInfoAction; +import org.opensearch.security.rest.SecurityConfigUpdateAction; import org.opensearch.security.rest.SecurityHealthAction; import org.opensearch.security.rest.SecurityInfoAction; +import org.opensearch.security.rest.SecurityWhoAmIAction; import org.opensearch.security.rest.TenantInfoAction; import org.opensearch.security.securityconf.DynamicConfigFactory; +import org.opensearch.security.setting.OpensearchDynamicSetting; +import org.opensearch.security.setting.TransportPassiveAuthSetting; +import org.opensearch.security.ssl.OpenSearchSecuritySSLPlugin; import org.opensearch.security.ssl.SslExceptionHandler; +import org.opensearch.security.ssl.http.netty.ValidatingDispatcher; +import org.opensearch.security.ssl.rest.SecuritySSLCertsInfoAction; +import org.opensearch.security.ssl.rest.SecuritySSLReloadCertsAction; +import org.opensearch.security.ssl.transport.DefaultPrincipalExtractor; import org.opensearch.security.ssl.transport.SecuritySSLNettyTransport; import org.opensearch.security.ssl.util.SSLConfigConstants; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.HeaderHelper; +import org.opensearch.security.support.ModuleInfo; +import org.opensearch.security.support.ReflectionHelper; +import org.opensearch.security.support.SecuritySettings; +import org.opensearch.security.support.SecurityUtils; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.transport.DefaultInterClusterRequestEvaluator; import org.opensearch.security.transport.InterClusterRequestEvaluator; +import org.opensearch.security.transport.SecurityInterceptor; import org.opensearch.security.user.User; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; @@ -165,21 +187,6 @@ import org.opensearch.transport.TransportService; import org.opensearch.watcher.ResourceWatcherService; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ClusterInfoHolder; -import org.opensearch.security.configuration.CompatConfig; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.configuration.DlsFlsRequestValve; -import org.opensearch.security.ssl.http.netty.ValidatingDispatcher; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.HeaderHelper; -import org.opensearch.security.support.ModuleInfo; -import org.opensearch.security.support.ReflectionHelper; -import org.opensearch.security.support.WildcardMatcher; -import org.opensearch.security.support.SecurityUtils; -import org.opensearch.security.support.SecuritySettings; -import com.google.common.collect.Lists; - public final class OpenSearchSecurityPlugin extends OpenSearchSecuritySSLPlugin implements ClusterPlugin, MapperPlugin { private static final String KEYWORD = ".keyword"; diff --git a/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java b/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java index 0aa69f9bee..61e73200f0 100644 --- a/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java +++ b/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java @@ -33,8 +33,9 @@ import java.io.IOException; import java.util.List; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.nodes.BaseNodeRequest; @@ -45,13 +46,12 @@ import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; -import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.TransportService; - import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.securityconf.DynamicConfigFactory; import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.threadpool.ThreadPool; +import org.opensearch.transport.TransportService; public class TransportConfigUpdateAction extends diff --git a/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java b/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java index cfa5ffa61c..636d0062ec 100644 --- a/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java +++ b/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java @@ -36,14 +36,13 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.settings.Settings; -import org.opensearch.tasks.Task; -import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.TransportService; - import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; import org.opensearch.security.user.User; +import org.opensearch.tasks.Task; +import org.opensearch.threadpool.ThreadPool; +import org.opensearch.transport.TransportService; public class TransportWhoAmIAction extends diff --git a/src/main/java/org/opensearch/security/action/whoami/WhoAmIRequestBuilder.java b/src/main/java/org/opensearch/security/action/whoami/WhoAmIRequestBuilder.java index 6125927f63..6c82e19e31 100644 --- a/src/main/java/org/opensearch/security/action/whoami/WhoAmIRequestBuilder.java +++ b/src/main/java/org/opensearch/security/action/whoami/WhoAmIRequestBuilder.java @@ -30,12 +30,12 @@ package org.opensearch.security.action.whoami; +import java.io.IOException; + import org.opensearch.action.ActionRequestBuilder; import org.opensearch.client.ClusterAdminClient; import org.opensearch.client.OpenSearchClient; -import java.io.IOException; - public class WhoAmIRequestBuilder extends ActionRequestBuilder { public WhoAmIRequestBuilder(final ClusterAdminClient client) throws IOException { diff --git a/src/main/java/org/opensearch/security/auditlog/AuditLog.java b/src/main/java/org/opensearch/security/auditlog/AuditLog.java index a7cda20025..e9c974cf4c 100644 --- a/src/main/java/org/opensearch/security/auditlog/AuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/AuditLog.java @@ -33,7 +33,6 @@ import java.io.Closeable; import java.util.Map; -import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; import org.opensearch.index.engine.Engine.Index; @@ -41,6 +40,7 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestRequest; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; diff --git a/src/main/java/org/opensearch/security/auditlog/AuditLogSslExceptionHandler.java b/src/main/java/org/opensearch/security/auditlog/AuditLogSslExceptionHandler.java index 9e00a1d2c6..8999e41b48 100644 --- a/src/main/java/org/opensearch/security/auditlog/AuditLogSslExceptionHandler.java +++ b/src/main/java/org/opensearch/security/auditlog/AuditLogSslExceptionHandler.java @@ -32,11 +32,10 @@ import org.opensearch.OpenSearchException; import org.opensearch.rest.RestRequest; +import org.opensearch.security.ssl.SslExceptionHandler; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; -import org.opensearch.security.ssl.SslExceptionHandler; - public class AuditLogSslExceptionHandler implements SslExceptionHandler{ private final AuditLog auditLog; diff --git a/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java b/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java index 06761f5636..463c2a4abf 100644 --- a/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.util.Map; -import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; import org.opensearch.index.engine.Engine.Index; @@ -41,6 +40,7 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestRequest; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; diff --git a/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java b/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java index 2f4aa7ece2..85fdc147d9 100644 --- a/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java +++ b/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java @@ -15,12 +15,11 @@ package org.opensearch.security.auditlog.config; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.compliance.ComplianceConfig; -import org.opensearch.security.dlic.rest.support.Utils; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.WildcardMatcher; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -32,13 +31,14 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.apache.logging.log4j.Logger; -import org.opensearch.common.settings.Settings; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.compliance.ComplianceConfig; +import org.opensearch.security.dlic.rest.support.Utils; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.WildcardMatcher; import static org.opensearch.security.DefaultObjectMapper.getOrDefault; diff --git a/src/main/java/org/opensearch/security/auditlog/config/ThreadPoolConfig.java b/src/main/java/org/opensearch/security/auditlog/config/ThreadPoolConfig.java index 2b426d8627..19a27618e7 100644 --- a/src/main/java/org/opensearch/security/auditlog/config/ThreadPoolConfig.java +++ b/src/main/java/org/opensearch/security/auditlog/config/ThreadPoolConfig.java @@ -15,8 +15,8 @@ package org.opensearch.security.auditlog.config; -import org.opensearch.security.support.ConfigConstants; import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; public class ThreadPoolConfig { private static final int DEFAULT_THREAD_POOL_SIZE = 10; diff --git a/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java b/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java index 5613508a8a..b201bd0957 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java @@ -30,12 +30,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.config.AuditConfig; +import com.fasterxml.jackson.databind.JsonNode; +import com.flipkart.zjsonpatch.JsonDiff; import com.google.common.annotations.VisibleForTesting; +import com.google.common.io.BaseEncoding; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.SpecialPermission; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkShardRequest; @@ -63,19 +65,17 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestRequest; -import org.opensearch.tasks.Task; -import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.TransportRequest; - +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.Base64Helper; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; -import com.fasterxml.jackson.databind.JsonNode; -import com.flipkart.zjsonpatch.JsonDiff; -import com.google.common.io.BaseEncoding; +import org.opensearch.tasks.Task; +import org.opensearch.threadpool.ThreadPool; +import org.opensearch.transport.TransportRequest; import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; diff --git a/src/main/java/org/opensearch/security/auditlog/impl/AuditCategory.java b/src/main/java/org/opensearch/security/auditlog/impl/AuditCategory.java index 2bac7960bc..9d8b262433 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AuditCategory.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AuditCategory.java @@ -15,15 +15,15 @@ package org.opensearch.security.auditlog.impl; -import org.opensearch.security.support.ConfigConstants; - -import com.google.common.collect.ImmutableSet; -import org.opensearch.common.settings.Settings; - import java.util.Collection; import java.util.Collections; import java.util.Set; +import com.google.common.collect.ImmutableSet; + +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; + public enum AuditCategory { BAD_HEADERS, FAILED_LOGIN, diff --git a/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java b/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java index 516ae7a980..6a9c131eda 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java @@ -21,7 +21,8 @@ import java.security.PrivilegedAction; import java.util.Map; -import org.opensearch.security.auditlog.config.AuditConfig; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.SpecialPermission; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -35,13 +36,12 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestRequest; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.auditlog.routing.AuditMessageRouter; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; -import org.greenrobot.eventbus.Subscribe; - public final class AuditLogImpl extends AbstractAuditLog { private final AuditMessageRouter messageRouter; diff --git a/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java b/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java index 8c3a19586e..3f1744942c 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java @@ -28,12 +28,14 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.support.WildcardMatcher; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.codec.digest.DigestUtils; import org.apache.http.client.utils.URIBuilder; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + import org.opensearch.ExceptionsHelper; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.Strings; @@ -45,14 +47,12 @@ import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestRequest; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - import org.opensearch.security.auditlog.AuditLog.Operation; import org.opensearch.security.auditlog.AuditLog.Origin; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.dlic.rest.support.Utils; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.support.WildcardMatcher; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java b/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java index 2995b513b6..866479444a 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java @@ -24,8 +24,9 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.DocWriteRequest; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; @@ -56,12 +57,11 @@ import org.opensearch.index.reindex.DeleteByQueryRequest; import org.opensearch.index.reindex.ReindexRequest; import org.opensearch.index.reindex.UpdateByQueryRequest; -import org.opensearch.tasks.Task; -import org.opensearch.transport.TransportRequest; - import org.opensearch.security.auditlog.AuditLog.Origin; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.WildcardMatcher; +import org.opensearch.tasks.Task; +import org.opensearch.transport.TransportRequest; public final class RequestResolver { diff --git a/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java b/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java index 6f8f5fff95..1889adbc27 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java @@ -20,10 +20,10 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.opensearch.security.auditlog.config.ThreadPoolConfig; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.security.auditlog.config.ThreadPoolConfig; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java b/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java index b2d6402c58..85e60c5681 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java @@ -21,21 +21,21 @@ import java.util.List; import java.util.Map; -import org.opensearch.security.auditlog.config.ThreadPoolConfig; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; -import org.opensearch.threadpool.ThreadPool; - -import org.opensearch.security.auditlog.impl.AuditMessage; +import org.opensearch.security.auditlog.config.ThreadPoolConfig; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; import org.opensearch.security.auditlog.sink.SinkProvider; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.threadpool.ThreadPool; import static com.google.common.base.Preconditions.checkState; diff --git a/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java b/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java index db9652832d..3080424c2c 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java @@ -19,16 +19,16 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.Logger; +import com.google.common.util.concurrent.Uninterruptibles; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormatter; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.support.ConfigConstants; -import com.google.common.util.concurrent.Uninterruptibles; public abstract class AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/DebugSink.java b/src/main/java/org/opensearch/security/auditlog/sink/DebugSink.java index cc1c63fa11..d5f8e3c4fa 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/DebugSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/DebugSink.java @@ -16,7 +16,6 @@ package org.opensearch.security.auditlog.sink; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; public final class DebugSink extends AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java b/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java index 12027bdf7c..c7d3676808 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java @@ -24,10 +24,10 @@ import java.util.Collections; import java.util.List; -import org.opensearch.common.settings.Settings; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.httpclient.HttpClient; import org.opensearch.security.httpclient.HttpClient.HttpClientBuilder; diff --git a/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java b/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java index 7a2323d26c..265612096f 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java @@ -18,19 +18,19 @@ import java.io.IOException; import java.nio.file.Path; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; -import org.opensearch.threadpool.ThreadPool; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; +import org.opensearch.threadpool.ThreadPool; public final class InternalOpenSearchSink extends AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java b/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java index d107387529..2d3a1fdede 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java @@ -29,9 +29,9 @@ import org.apache.kafka.clients.producer.RecordMetadata; import org.apache.kafka.common.serialization.LongSerializer; import org.apache.kafka.common.serialization.StringSerializer; + import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; public class KafkaSink extends AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java b/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java index 2890a216ad..b541f81560 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java @@ -16,10 +16,10 @@ package org.opensearch.security.auditlog.sink; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; public final class Log4JSink extends AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/NoopSink.java b/src/main/java/org/opensearch/security/auditlog/sink/NoopSink.java index f8b69896d5..69d76b1626 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/NoopSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/NoopSink.java @@ -16,7 +16,6 @@ package org.opensearch.security.auditlog.sink; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; public final class NoopSink extends AuditLogSink { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java b/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java index bc637844a5..7535420fc4 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java @@ -20,14 +20,14 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; -import org.opensearch.threadpool.ThreadPool; - import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.threadpool.ThreadPool; public class SinkProvider { diff --git a/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java b/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java index fb8f1f493e..bdb00a8bfb 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java @@ -39,9 +39,9 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.TrustStrategy; + import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; diff --git a/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java b/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java index 796b7579e2..d8d33c55b0 100644 --- a/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java +++ b/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java @@ -31,7 +31,6 @@ package org.opensearch.security.auth; import org.opensearch.OpenSearchSecurityException; - import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java b/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java index 286e73f938..444c07ef8b 100644 --- a/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java +++ b/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java @@ -31,7 +31,6 @@ package org.opensearch.security.auth; import org.opensearch.OpenSearchSecurityException; - import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/auth/BackendRegistry.java b/src/main/java/org/opensearch/security/auth/BackendRegistry.java index 2d434d560a..ab77fed6fe 100644 --- a/src/main/java/org/opensearch/security/auth/BackendRegistry.java +++ b/src/main/java/org/opensearch/security/auth/BackendRegistry.java @@ -42,8 +42,16 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.collect.Multimap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; @@ -63,14 +71,6 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import org.greenrobot.eventbus.Subscribe; - -import com.google.common.base.Strings; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.collect.Multimap; public class BackendRegistry { diff --git a/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java b/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java index b0bd5033ad..8cc05891b6 100644 --- a/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java +++ b/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java @@ -34,7 +34,6 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.user.AuthCredentials; /** diff --git a/src/main/java/org/opensearch/security/auth/RolesInjector.java b/src/main/java/org/opensearch/security/auth/RolesInjector.java index 9a11543657..4c98d82e8c 100644 --- a/src/main/java/org/opensearch/security/auth/RolesInjector.java +++ b/src/main/java/org/opensearch/security/auth/RolesInjector.java @@ -15,19 +15,20 @@ package org.opensearch.security.auth; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.user.User; +import java.util.Set; + import com.google.common.collect.ImmutableSet; import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.user.User; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; -import java.util.Set; - /** * This is used to inject opendistro-roles into the request when there is no user involved, like periodic plugin * background jobs. The roles injection is done using thread-context at transport layer only. You can't inject diff --git a/src/main/java/org/opensearch/security/auth/UserInjector.java b/src/main/java/org/opensearch/security/auth/UserInjector.java index d85ab610ea..298c100959 100644 --- a/src/main/java/org/opensearch/security/auth/UserInjector.java +++ b/src/main/java/org/opensearch/security/auth/UserInjector.java @@ -36,8 +36,10 @@ import java.util.Arrays; import java.util.Map; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.rest.RestRequest; @@ -48,8 +50,6 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import com.google.common.base.Strings; - public class UserInjector { protected final Logger log = LogManager.getLogger(UserInjector.class); diff --git a/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java b/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java index 6e4362f93d..363645cd90 100644 --- a/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java +++ b/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java @@ -19,13 +19,12 @@ import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalNotification; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class HeapBasedClientBlockRegistry implements ClientBlockRegistry { diff --git a/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java b/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java index 1cba2022e0..d03f2b529a 100644 --- a/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java +++ b/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java @@ -40,14 +40,14 @@ import java.util.Map.Entry; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; -import org.opensearch.OpenSearchSecurityException; +import org.greenrobot.eventbus.Subscribe; +import org.opensearch.OpenSearchSecurityException; import org.opensearch.security.auth.AuthenticationBackend; import org.opensearch.security.auth.AuthorizationBackend; import org.opensearch.security.securityconf.InternalUsersModel; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import org.greenrobot.eventbus.Subscribe; public class InternalAuthenticationBackend implements AuthenticationBackend, AuthorizationBackend { diff --git a/src/main/java/org/opensearch/security/auth/internal/NoOpAuthenticationBackend.java b/src/main/java/org/opensearch/security/auth/internal/NoOpAuthenticationBackend.java index 4587d3e9c4..85723651e4 100644 --- a/src/main/java/org/opensearch/security/auth/internal/NoOpAuthenticationBackend.java +++ b/src/main/java/org/opensearch/security/auth/internal/NoOpAuthenticationBackend.java @@ -33,7 +33,6 @@ import java.nio.file.Path; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthenticationBackend; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/auth/internal/NoOpAuthorizationBackend.java b/src/main/java/org/opensearch/security/auth/internal/NoOpAuthorizationBackend.java index 794db77eea..d0c474089b 100644 --- a/src/main/java/org/opensearch/security/auth/internal/NoOpAuthorizationBackend.java +++ b/src/main/java/org/opensearch/security/auth/internal/NoOpAuthorizationBackend.java @@ -33,7 +33,6 @@ import java.nio.file.Path; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthorizationBackend; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/auth/limiting/AbstractRateLimiter.java b/src/main/java/org/opensearch/security/auth/limiting/AbstractRateLimiter.java index fb2794340c..3f603437a0 100644 --- a/src/main/java/org/opensearch/security/auth/limiting/AbstractRateLimiter.java +++ b/src/main/java/org/opensearch/security/auth/limiting/AbstractRateLimiter.java @@ -21,7 +21,6 @@ import java.nio.file.Path; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthFailureListener; import org.opensearch.security.auth.blocking.ClientBlockRegistry; import org.opensearch.security.auth.blocking.HeapBasedClientBlockRegistry; diff --git a/src/main/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiter.java b/src/main/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiter.java index 446dcb9319..42f1d1f165 100644 --- a/src/main/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiter.java +++ b/src/main/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiter.java @@ -21,7 +21,6 @@ import java.nio.file.Path; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthFailureListener; import org.opensearch.security.auth.blocking.ClientBlockRegistry; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiter.java b/src/main/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiter.java index 79dc73db7e..7fe5ac05d6 100644 --- a/src/main/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiter.java +++ b/src/main/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiter.java @@ -21,7 +21,6 @@ import java.nio.file.Path; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthFailureListener; import org.opensearch.security.auth.blocking.ClientBlockRegistry; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java index 130591bc85..2e0c10dbac 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java @@ -37,8 +37,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.config.AuditConfig; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonCreator; @@ -47,23 +45,25 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.Logger; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.Strings; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import org.opensearch.common.Strings; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import static org.opensearch.security.DefaultObjectMapper.getOrDefault; diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java index f3f335e8b2..9a9061742e 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java @@ -17,8 +17,9 @@ import java.util.Objects; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.index.IndexService; import org.opensearch.index.engine.Engine.Delete; @@ -28,7 +29,6 @@ import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.ShardId; - import org.opensearch.security.auditlog.AuditLog; public final class ComplianceIndexingOperationListenerImpl extends ComplianceIndexingOperationListener { diff --git a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java index b2710da0a3..eb9b8279ac 100644 --- a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java +++ b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java @@ -23,9 +23,11 @@ import java.util.Objects; import java.util.function.Function; -import org.apache.logging.log4j.Logger; +import com.github.wnameless.json.flattener.JsonFlattener; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.index.FieldInfo; + import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.support.XContentMapValues; @@ -33,13 +35,11 @@ import org.opensearch.index.IndexService; import org.opensearch.index.mapper.Uid; import org.opensearch.index.shard.ShardId; - import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.HeaderHelper; import org.opensearch.security.support.SourceFieldsContext; import org.opensearch.security.support.WildcardMatcher; -import com.github.wnameless.json.flattener.JsonFlattener; //TODO We need to deal with caching!! //Currently we disable caching (and realtime requests) when FLS or DLS is applied diff --git a/src/main/java/org/opensearch/security/configuration/AdminDNs.java b/src/main/java/org/opensearch/security/configuration/AdminDNs.java index f5fd217ed3..b61e3883d9 100644 --- a/src/main/java/org/opensearch/security/configuration/AdminDNs.java +++ b/src/main/java/org/opensearch/security/configuration/AdminDNs.java @@ -41,16 +41,15 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableMap; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; +import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; -import com.google.common.collect.ImmutableMap; - public class AdminDNs { protected final Logger log = LogManager.getLogger(AdminDNs.class); diff --git a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java index c2ba9a2470..4f42266471 100644 --- a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java +++ b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java @@ -33,8 +33,9 @@ import java.util.Iterator; import java.util.List; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.LegacyESVersion; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; diff --git a/src/main/java/org/opensearch/security/configuration/CompatConfig.java b/src/main/java/org/opensearch/security/configuration/CompatConfig.java index 047f09a6f9..c61d88d3ec 100644 --- a/src/main/java/org/opensearch/security/configuration/CompatConfig.java +++ b/src/main/java/org/opensearch/security/configuration/CompatConfig.java @@ -30,14 +30,14 @@ package org.opensearch.security.configuration; -import org.opensearch.security.setting.OpensearchDynamicSetting; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; -import org.opensearch.env.Environment; +import org.apache.logging.log4j.Logger; import org.greenrobot.eventbus.Subscribe; +import org.opensearch.common.settings.Settings; +import org.opensearch.env.Environment; import org.opensearch.security.securityconf.DynamicConfigModel; +import org.opensearch.security.setting.OpensearchDynamicSetting; import org.opensearch.security.support.ConfigConstants; import static org.opensearch.security.support.ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY; diff --git a/src/main/java/org/opensearch/security/configuration/ConfigCallback.java b/src/main/java/org/opensearch/security/configuration/ConfigCallback.java index 844dc4a241..60255223d2 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigCallback.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigCallback.java @@ -31,7 +31,6 @@ package org.opensearch.security.configuration; import org.opensearch.action.get.MultiGetResponse.Failure; - import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; public interface ConfigCallback { diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java index 993a6f251c..31f5102483 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java @@ -39,11 +39,10 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.support.ConfigHelper; -import org.opensearch.security.support.SecurityUtils; -import org.apache.logging.log4j.Logger; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.get.GetResponse; @@ -59,13 +58,14 @@ import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.threadpool.ThreadPool; - -import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.ConfigHelper; +import org.opensearch.security.support.SecurityUtils; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java index 2f247b7224..6e0afbaa9f 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java @@ -46,13 +46,14 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.support.SecurityUtils; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchException; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; +import org.opensearch.OpenSearchException; import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; @@ -67,17 +68,16 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; import org.opensearch.env.Environment; -import org.opensearch.security.ssl.util.ExceptionUtils; -import org.opensearch.threadpool.ThreadPool; - import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.securityconf.DynamicConfigFactory; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.ConfigHelper; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; +import org.opensearch.security.support.SecurityUtils; +import org.opensearch.threadpool.ThreadPool; public class ConfigurationRepository { private static final Logger LOGGER = LogManager.getLogger(ConfigurationRepository.class); diff --git a/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java b/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java index 86d518b17a..0037767ea6 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java @@ -25,8 +25,9 @@ import java.util.function.Function; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java index 716b051fce..cc9b816929 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java @@ -31,7 +31,9 @@ import java.util.Set; import java.util.function.Function; -import org.opensearch.security.compliance.ComplianceConfig; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterators; import org.apache.lucene.codecs.StoredFieldsReader; import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.index.DirectoryReader; @@ -63,6 +65,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.automaton.CompiledAutomaton; + import org.opensearch.ExceptionsHelper; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesArray; @@ -76,8 +79,8 @@ import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.IndexService; import org.opensearch.index.shard.ShardId; - import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.compliance.FieldReadCallback; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.support.ConfigConstants; @@ -85,9 +88,6 @@ import org.opensearch.security.support.MapUtils; import org.opensearch.security.support.SecurityUtils; import org.opensearch.security.support.WildcardMatcher; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterators; class DlsFlsFilterLeafReader extends SequentialStoredFieldsLeafReader { diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java index bc1f588f94..bd8219eac0 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java @@ -19,15 +19,22 @@ import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.*; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.function.Consumer; import java.util.stream.StreamSupport; import com.google.common.collect.ImmutableList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.util.BytesRef; + import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; @@ -75,8 +82,6 @@ import org.opensearch.security.support.HeaderHelper; import org.opensearch.security.support.SecurityUtils; import org.opensearch.threadpool.ThreadPool; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; public class DlsFlsValveImpl implements DlsFlsRequestValve { diff --git a/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java b/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java index 7b5ba7f8cc..07af2cad30 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java +++ b/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java @@ -21,8 +21,10 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; -import org.apache.logging.log4j.Logger; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; @@ -31,6 +33,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.join.BitSetProducer; import org.apache.lucene.search.join.ToChildBlockJoinQuery; + import org.opensearch.common.xcontent.DeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentParser; @@ -42,9 +45,6 @@ import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.security.queries.QueryBuilderTraverser; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; - public final class DlsQueryParser { diff --git a/src/main/java/org/opensearch/security/configuration/MaskedField.java b/src/main/java/org/opensearch/security/configuration/MaskedField.java index 98f5f08e24..5a6ceefa63 100644 --- a/src/main/java/org/opensearch/security/configuration/MaskedField.java +++ b/src/main/java/org/opensearch/security/configuration/MaskedField.java @@ -23,12 +23,11 @@ import java.util.List; import java.util.Objects; +import com.google.common.base.Splitter; import org.apache.lucene.util.BytesRef; import org.bouncycastle.crypto.digests.Blake2bDigest; import org.bouncycastle.util.encoders.Hex; -import com.google.common.base.Splitter; - public class MaskedField { private final String name; diff --git a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java index b6e63bec6f..11447d8c9b 100644 --- a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java +++ b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java @@ -18,8 +18,10 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableMap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; @@ -47,14 +49,11 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.threadpool.ThreadPool; - import org.opensearch.security.privileges.PrivilegesInterceptor; import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.DynamicConfigModel; import org.opensearch.security.user.User; - -import com.google.common.collect.ImmutableMap; +import org.opensearch.threadpool.ThreadPool; public class PrivilegesInterceptorImpl extends PrivilegesInterceptor { diff --git a/src/main/java/org/opensearch/security/configuration/Salt.java b/src/main/java/org/opensearch/security/configuration/Salt.java index 68bd9caac9..188a206a53 100644 --- a/src/main/java/org/opensearch/security/configuration/Salt.java +++ b/src/main/java/org/opensearch/security/configuration/Salt.java @@ -15,16 +15,17 @@ package org.opensearch.security.configuration; -import org.opensearch.security.support.ConfigConstants; +import java.nio.BufferUnderflowException; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; - -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; +import org.opensearch.security.support.ConfigConstants; /** * Configuration class to store salt used for FLS anonymization diff --git a/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java b/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java index 0bf91c2984..5709040d32 100644 --- a/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java +++ b/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java @@ -21,11 +21,11 @@ import java.util.Set; import java.util.function.LongSupplier; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.support.SecurityUtils; +import com.google.common.collect.Sets; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.Query; + import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.index.IndexService; @@ -33,13 +33,12 @@ import org.opensearch.index.query.QueryShardContext; import org.opensearch.index.shard.ShardId; import org.opensearch.index.shard.ShardUtils; - import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.compliance.ComplianceIndexingOperationListener; +import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; - -import com.google.common.collect.Sets; +import org.opensearch.security.support.SecurityUtils; public class SecurityFlsDlsIndexSearcherWrapper extends SecurityIndexSearcherWrapper { diff --git a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java index af291094e5..524709ad5e 100644 --- a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java +++ b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java @@ -33,22 +33,22 @@ import java.io.IOException; import java.util.Set; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.ConfigModel; -import org.opensearch.security.support.WildcardMatcher; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.index.DirectoryReader; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.common.CheckedFunction; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.index.Index; import org.opensearch.index.IndexService; -import org.greenrobot.eventbus.Subscribe; - +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.ConfigModel; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; public class SecurityIndexSearcherWrapper implements CheckedFunction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java index 8ed778af05..63584b3cac 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java @@ -21,9 +21,11 @@ import java.util.Collections; import java.util.Objects; -import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.Logger; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionListener; import org.opensearch.action.index.IndexRequest; @@ -47,6 +49,7 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateNodeResponse; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; @@ -60,16 +63,13 @@ import org.opensearch.security.securityconf.DynamicConfigFactory; import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.StaticDefinable; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; - public abstract class AbstractApiAction extends BaseRestHandler { protected final Logger log = LogManager.getLogger(this.getClass()); diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/AccountApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/AccountApiAction.java index df264d138d..c910f6eea5 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/AccountApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/AccountApiAction.java @@ -15,21 +15,15 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.dlic.rest.validation.AccountValidator; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.Hashed; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.SecurityJsonNode; -import org.opensearch.security.user.User; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import java.util.Set; + import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -45,16 +39,23 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.AccountValidator; +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.Hashed; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.SecurityJsonNode; +import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; -import java.util.Set; -import com.google.common.collect.ImmutableList; - -import static org.opensearch.security.dlic.rest.support.Utils.hash; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; +import static org.opensearch.security.dlic.rest.support.Utils.hash; /** * Rest API action to fetch or update account details of the signed-in user. diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiAction.java index cc02284e30..38501dd655 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiAction.java @@ -18,6 +18,8 @@ import java.nio.file.Path; import java.util.List; +import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -32,12 +34,10 @@ import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.ActionGroupValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.security.securityconf.impl.CType; -import com.google.common.collect.ImmutableList; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class ActionGroupsApiAction extends PatchableResourceApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/AuditApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/AuditApiAction.java index 1287d350a2..9829ec14cf 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/AuditApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/AuditApiAction.java @@ -15,6 +15,24 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableList; + +import org.opensearch.client.Client; +import org.opensearch.cluster.service.ClusterService; +import org.opensearch.common.bytes.BytesReference; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.rest.RestChannel; +import org.opensearch.rest.RestController; +import org.opensearch.rest.RestRequest; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.config.AuditConfig; @@ -28,25 +46,8 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.ssl.transport.PrincipalExtractor; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; -import org.opensearch.client.Client; -import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.rest.RestChannel; -import org.opensearch.rest.RestController; -import org.opensearch.rest.RestRequest; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; -import java.util.Map; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; /** diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/AuthTokenProcessorAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/AuthTokenProcessorAction.java index ae8198d3a6..a6d3dfe403 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/AuthTokenProcessorAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/AuthTokenProcessorAction.java @@ -15,14 +15,11 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.dlic.rest.validation.NoOpValidator; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.ssl.transport.PrincipalExtractor; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.client.Client; @@ -34,13 +31,16 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.NoOpValidator; +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class AuthTokenProcessorAction extends AbstractApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 66afca528a..9bb42eb2db 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -19,6 +19,9 @@ import java.nio.file.Path; import java.util.List; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; + import org.opensearch.action.ActionListener; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -38,13 +41,10 @@ import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.NoOpValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import com.fasterxml.jackson.databind.JsonNode; -import org.opensearch.security.securityconf.impl.CType; -import com.google.common.collect.ImmutableList; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class FlushCacheApiAction extends AbstractApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/InternalUsersApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/InternalUsersApiAction.java index f1754bbfde..1b141c780b 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/InternalUsersApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/InternalUsersApiAction.java @@ -15,21 +15,15 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.dlic.rest.validation.InternalUsersValidator; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.Hashed; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.support.SecurityJsonNode; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; +import com.google.common.collect.ImmutableList; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -41,15 +35,22 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.InternalUsersValidator; +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.Hashed; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.support.SecurityJsonNode; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; -import com.google.common.collect.ImmutableList; - -import static org.opensearch.security.dlic.rest.support.Utils.hash; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; +import static org.opensearch.security.dlic.rest.support.Utils.hash; public class InternalUsersApiAction extends PatchableResourceApiAction { private static final List routes = addRoutesPrefix(ImmutableList.of( diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/MigrateApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/MigrateApiAction.java index 76ada2be01..055a022a82 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/MigrateApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/MigrateApiAction.java @@ -20,10 +20,11 @@ import java.util.Collections; import java.util.List; -import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.Version; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; + import org.opensearch.LegacyESVersion; +import org.opensearch.Version; import org.opensearch.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.bulk.BulkRequestBuilder; @@ -46,19 +47,17 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.NoOpValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.securityconf.Migration; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.threadpool.ThreadPool; - -import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.securityconf.impl.NodesDn; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.securityconf.impl.WhitelistingSettings; import org.opensearch.security.securityconf.impl.v6.ActionGroupsV6; import org.opensearch.security.securityconf.impl.v6.ConfigV6; import org.opensearch.security.securityconf.impl.v6.InternalUserV6; @@ -70,8 +69,8 @@ import org.opensearch.security.securityconf.impl.v7.RoleMappingsV7; import org.opensearch.security.securityconf.impl.v7.RoleV7; import org.opensearch.security.securityconf.impl.v7.TenantV7; - -import com.google.common.collect.ImmutableList; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/NodesDnApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/NodesDnApiAction.java index 152b8ae1a9..403f9adc1f 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/NodesDnApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/NodesDnApiAction.java @@ -15,20 +15,14 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.dlic.rest.validation.NodesDnValidator; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.opensearch.security.securityconf.impl.NodesDn; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.tools.SecurityAdmin; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -38,13 +32,19 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.NodesDnValidator; +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.NodesDn; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; /** diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java index 3c617afb96..2dac1e2dd2 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java @@ -20,9 +20,14 @@ import java.nio.file.Path; import java.util.Iterator; -import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.Logger; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.flipkart.zjsonpatch.JsonPatch; +import com.flipkart.zjsonpatch.JsonPatchApplicationException; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -35,22 +40,17 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.flipkart.zjsonpatch.JsonPatch; -import com.flipkart.zjsonpatch.JsonPatchApplicationException; - public abstract class PatchableResourceApiAction extends AbstractApiAction { protected final Logger log = LogManager.getLogger(this.getClass()); diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/PermissionsInfoAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/PermissionsInfoAction.java index 55dbdd2b22..65f6ba465c 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/PermissionsInfoAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/PermissionsInfoAction.java @@ -24,6 +24,7 @@ import java.util.Set; import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.service.ClusterService; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java b/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java index 93c05b5232..f80ca1ec8b 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java @@ -29,8 +29,9 @@ import java.util.Map.Entry; import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.rest.RestRequest; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/RolesApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/RolesApiAction.java index 6c6a4a5731..b9f42dd92c 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RolesApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RolesApiAction.java @@ -18,6 +18,8 @@ import java.nio.file.Path; import java.util.List; +import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -32,13 +34,10 @@ import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.RolesValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.security.securityconf.impl.CType; - -import com.google.common.collect.ImmutableList; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class RolesApiAction extends PatchableResourceApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/RolesMappingApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/RolesMappingApiAction.java index 53fd735b69..63567f9441 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RolesMappingApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RolesMappingApiAction.java @@ -19,10 +19,9 @@ import java.nio.file.Path; import java.util.List; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.ImmutableList; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -33,17 +32,18 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.RolesMappingValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.security.securityconf.impl.CType; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class RolesMappingApiAction extends PatchableResourceApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigAction.java index 243a442e90..0cae729b66 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigAction.java @@ -20,10 +20,9 @@ import java.util.Collections; import java.util.List; -import org.opensearch.security.dlic.rest.validation.SecurityConfigValidator; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -37,13 +36,14 @@ import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.SecurityConfigValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import com.fasterxml.jackson.databind.JsonNode; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class SecurityConfigAction extends PatchableResourceApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/TenantsApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/TenantsApiAction.java index 7c03bddf3d..bc82bd29e9 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/TenantsApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/TenantsApiAction.java @@ -34,7 +34,8 @@ import java.nio.file.Path; import java.util.List; -import org.opensearch.security.securityconf.impl.CType; +import com.google.common.collect.ImmutableList; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -49,11 +50,10 @@ import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.TenantValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import com.google.common.collect.ImmutableList; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class TenantsApiAction extends PatchableResourceApiAction { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/ValidateApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/ValidateApiAction.java index 70402acbab..2cbd4034b0 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/ValidateApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/ValidateApiAction.java @@ -20,7 +20,8 @@ import java.util.Collections; import java.util.List; -import org.opensearch.security.auditlog.config.AuditConfig; +import com.fasterxml.jackson.databind.JsonNode; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; @@ -32,16 +33,13 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.dlic.rest.validation.NoOpValidator; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.securityconf.Migration; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.threadpool.ThreadPool; - -import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.securityconf.impl.v6.ActionGroupsV6; @@ -55,6 +53,8 @@ import org.opensearch.security.securityconf.impl.v7.RoleMappingsV7; import org.opensearch.security.securityconf.impl.v7.RoleV7; import org.opensearch.security.securityconf.impl.v7.TenantV7; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/WhitelistApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/WhitelistApiAction.java index 63d27678a3..b71d0f21ae 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/WhitelistApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/WhitelistApiAction.java @@ -16,20 +16,13 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.dlic.rest.validation.WhitelistValidator; -import org.opensearch.security.privileges.PrivilegesEvaluator; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.tools.SecurityAdmin; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; + import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.ImmutableList; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -39,12 +32,18 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.dlic.rest.validation.WhitelistValidator; +import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; /** diff --git a/src/main/java/org/opensearch/security/dlic/rest/support/Utils.java b/src/main/java/org/opensearch/security/dlic/rest/support/Utils.java index 271b28c98e..28f5c204e6 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/support/Utils.java +++ b/src/main/java/org/opensearch/security/dlic/rest/support/Utils.java @@ -22,15 +22,21 @@ import java.security.SecureRandom; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.List; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; -import org.opensearch.OpenSearchParseException; + import org.opensearch.ExceptionsHelper; +import org.opensearch.OpenSearchParseException; import org.opensearch.SpecialPermission; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.NamedXContentRegistry; @@ -40,15 +46,8 @@ import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.rest.RestHandler.Route; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import org.opensearch.security.DefaultObjectMapper; -import com.google.common.collect.ImmutableList; - import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; public class Utils { diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java index 11cc6dc6f8..aea24faf99 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java @@ -23,10 +23,15 @@ import java.util.Map.Entry; import java.util.Set; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.Logger; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -35,13 +40,8 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.support.ConfigConstants; public abstract class AbstractConfigurationValidator { diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/AuditValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/AuditValidator.java index a69e50cf4f..27ee2aa28a 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/AuditValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/AuditValidator.java @@ -15,15 +15,16 @@ package org.opensearch.security.dlic.rest.validation; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.auditlog.impl.AuditCategory; +import java.util.Set; + import com.google.common.collect.ImmutableSet; + import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.rest.RestRequest; - -import java.util.Set; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; +import org.opensearch.security.auditlog.impl.AuditCategory; public class AuditValidator extends AbstractConfigurationValidator { diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/CredentialsValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/CredentialsValidator.java index 3a48beee9d..fc1d8e61a6 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/CredentialsValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/CredentialsValidator.java @@ -15,8 +15,9 @@ package org.opensearch.security.dlic.rest.validation; -import org.opensearch.security.ssl.util.Utils; -import org.opensearch.security.support.ConfigConstants; +import java.util.Map; +import java.util.regex.Pattern; + import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.compress.NotXContentException; @@ -24,9 +25,8 @@ import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestRequest; - -import java.util.Map; -import java.util.regex.Pattern; +import org.opensearch.security.ssl.util.Utils; +import org.opensearch.security.support.ConfigConstants; /** * Validator for validating password and hash present in the payload diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/RolesValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/RolesValidator.java index a1664e484a..950013a0f8 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/RolesValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/RolesValidator.java @@ -17,14 +17,14 @@ import java.util.List; -import org.opensearch.security.configuration.Salt; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.ReadContext; + import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.rest.RestRequest; - import org.opensearch.security.configuration.MaskedField; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.ReadContext; +import org.opensearch.security.configuration.Salt; public class RolesValidator extends AbstractConfigurationValidator { diff --git a/src/main/java/org/opensearch/security/filter/SecurityFilter.java b/src/main/java/org/opensearch/security/filter/SecurityFilter.java index 7fee09b379..34379e33fe 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityFilter.java @@ -35,18 +35,14 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.opensearch.security.auth.RolesInjector; -import org.opensearch.security.resolver.IndexResolverReplacer; -import org.opensearch.security.support.WildcardMatcher; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; -import org.opensearch.security.auth.BackendRegistry; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; @@ -72,20 +68,19 @@ import org.opensearch.action.support.ActionFilter; import org.opensearch.action.support.ActionFilterChain; import org.opensearch.action.update.UpdateRequest; -import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.logging.LoggerMessageFormat; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; -import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.index.reindex.DeleteByQueryRequest; import org.opensearch.index.reindex.UpdateByQueryRequest; import org.opensearch.rest.RestStatus; import org.opensearch.security.action.whoami.WhoAmIAction; -import org.opensearch.security.auth.UserInjector; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; +import org.opensearch.security.auth.RolesInjector; +import org.opensearch.security.auth.UserInjector; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.CompatConfig; @@ -93,14 +88,15 @@ import org.opensearch.security.http.XFFResolver; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.privileges.PrivilegesEvaluatorResponse; -import org.opensearch.tasks.Task; -import org.opensearch.threadpool.ThreadPool; - +import org.opensearch.security.resolver.IndexResolverReplacer; import org.opensearch.security.support.Base64Helper; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; import org.opensearch.security.support.SourceFieldsContext; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; +import org.opensearch.tasks.Task; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.OpenSearchSecurityPlugin.isActionTraceEnabled; import static org.opensearch.security.OpenSearchSecurityPlugin.traceAction; diff --git a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java index 335328b9c8..a029a9263f 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java @@ -31,14 +31,15 @@ package org.opensearch.security.filter; import java.nio.file.Path; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.net.ssl.SSLPeerUnverifiedException; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.dlic.rest.api.WhitelistApiAction; -import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.OpenSearchException; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; @@ -51,20 +52,18 @@ import org.opensearch.rest.RestStatus; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; +import org.opensearch.security.auth.BackendRegistry; +import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.CompatConfig; +import org.opensearch.security.securityconf.impl.WhitelistingSettings; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.ssl.util.SSLRequestHelper; +import org.opensearch.security.ssl.util.SSLRequestHelper.SSLInfo; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HTTPHelper; -import org.opensearch.threadpool.ThreadPool; - -import org.opensearch.security.ssl.util.SSLRequestHelper.SSLInfo; -import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.user.User; -import org.greenrobot.eventbus.Subscribe; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java index f52f7744bd..ccd4e38595 100644 --- a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java @@ -32,15 +32,15 @@ import java.nio.file.Path; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; - import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.support.HTTPHelper; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java index f3ee65f052..cd0ce90d12 100644 --- a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java @@ -39,14 +39,14 @@ import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java index 4320bd6009..fe592aa40e 100644 --- a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java @@ -33,19 +33,19 @@ import java.nio.file.Path; import java.util.regex.Pattern; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Predicates; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.AuthCredentials; -import com.google.common.base.Predicates; public class HTTPProxyAuthenticator implements HTTPAuthenticator { diff --git a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java index 0edb3552ea..18e0e8401a 100644 --- a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java +++ b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java @@ -52,11 +52,11 @@ import java.util.List; import java.util.regex.Pattern; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestRequest; - import org.opensearch.security.support.ConfigConstants; final class RemoteIpDetector { diff --git a/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java b/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java index 10a626ced5..b9261da2c4 100644 --- a/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java @@ -30,18 +30,17 @@ package org.opensearch.security.http; -import org.opensearch.security.ssl.http.netty.SecuritySSLNettyHttpServerTransport; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.BigArrays; import org.opensearch.common.xcontent.NamedXContentRegistry; -import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.SharedGroupFactory; - import org.opensearch.security.ssl.SecurityKeyStore; import org.opensearch.security.ssl.SslExceptionHandler; +import org.opensearch.security.ssl.http.netty.SecuritySSLNettyHttpServerTransport; import org.opensearch.security.ssl.http.netty.ValidatingDispatcher; +import org.opensearch.threadpool.ThreadPool; +import org.opensearch.transport.SharedGroupFactory; public class SecurityHttpServerTransport extends SecuritySSLNettyHttpServerTransport { diff --git a/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java b/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java index fba77fb2ac..edc6ab0d41 100644 --- a/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java @@ -30,6 +30,9 @@ package org.opensearch.security.http; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; + import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -40,9 +43,6 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; - public class SecurityNonSslHttpServerTransport extends Netty4HttpServerTransport { diff --git a/src/main/java/org/opensearch/security/http/XFFResolver.java b/src/main/java/org/opensearch/security/http/XFFResolver.java index e85e943a41..97c3bb8b43 100644 --- a/src/main/java/org/opensearch/security/http/XFFResolver.java +++ b/src/main/java/org/opensearch/security/http/XFFResolver.java @@ -32,8 +32,10 @@ import java.net.InetSocketAddress; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; @@ -42,7 +44,6 @@ import org.opensearch.security.securityconf.DynamicConfigModel; import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import org.greenrobot.eventbus.Subscribe; public class XFFResolver { diff --git a/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java b/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java index a73cf0a233..5c65ac7b2a 100644 --- a/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java @@ -34,17 +34,17 @@ import java.util.List; import java.util.Map.Entry; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Joiner; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.http.HTTPProxyAuthenticator; import org.opensearch.security.user.AuthCredentials; -import com.google.common.base.Joiner; public class HTTPExtendedProxyAuthenticator extends HTTPProxyAuthenticator{ diff --git a/src/main/java/org/opensearch/security/httpclient/HttpClient.java b/src/main/java/org/opensearch/security/httpclient/HttpClient.java index 853063598c..d9882bb20a 100644 --- a/src/main/java/org/opensearch/security/httpclient/HttpClient.java +++ b/src/main/java/org/opensearch/security/httpclient/HttpClient.java @@ -34,6 +34,7 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; +import com.google.common.collect.Lists; import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; @@ -46,8 +47,9 @@ import org.apache.http.ssl.PrivateKeyStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.support.WriteRequest.RefreshPolicy; @@ -58,8 +60,6 @@ import org.opensearch.client.RestHighLevelClient; import org.opensearch.common.xcontent.XContentType; -import com.google.common.collect.Lists; - public class HttpClient implements Closeable { public static class HttpClientBuilder { diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index e57a7176b6..4a934479ff 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -42,8 +42,11 @@ import java.util.regex.Pattern; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.Sets; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionRequest; import org.opensearch.action.IndicesRequest; @@ -85,23 +88,19 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.index.reindex.ReindexAction; +import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.configuration.ClusterInfoHolder; import org.opensearch.security.configuration.ConfigurationRepository; +import org.opensearch.security.resolver.IndexResolverReplacer; +import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.ConfigModel; import org.opensearch.security.securityconf.DynamicConfigModel; import org.opensearch.security.securityconf.SecurityRoles; -import org.opensearch.tasks.Task; -import org.opensearch.threadpool.ThreadPool; -import org.greenrobot.eventbus.Subscribe; - -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.resolver.IndexResolverReplacer; -import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; - -import com.google.common.collect.Sets; +import org.opensearch.tasks.Task; +import org.opensearch.threadpool.ThreadPool; import static org.opensearch.security.OpenSearchSecurityPlugin.traceAction; import static org.opensearch.security.support.ConfigConstants.OPENDISTRO_SECURITY_USER_INFO_THREAD_CONTEXT; diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluatorResponse.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluatorResponse.java index bbae1ad933..61c81018a2 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluatorResponse.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluatorResponse.java @@ -30,13 +30,13 @@ package org.opensearch.security.privileges; +import java.util.HashSet; +import java.util.Set; + import org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.EvaluatedDlsFlsConfig; -import java.util.HashSet; -import java.util.Set; - public class PrivilegesEvaluatorResponse { boolean allowed = false; Set missingPrivileges = new HashSet(); diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesInterceptor.java b/src/main/java/org/opensearch/security/privileges/PrivilegesInterceptor.java index d4aaf4f932..d7edde92e0 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesInterceptor.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesInterceptor.java @@ -38,11 +38,10 @@ import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.security.securityconf.DynamicConfigModel; -import org.opensearch.threadpool.ThreadPool; - import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; +import org.opensearch.security.securityconf.DynamicConfigModel; import org.opensearch.security.user.User; +import org.opensearch.threadpool.ThreadPool; public class PrivilegesInterceptor { diff --git a/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java index 99cada57b8..f156171b24 100644 --- a/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java @@ -18,17 +18,18 @@ import java.util.ArrayList; import java.util.List; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.resolver.IndexResolverReplacer; -import org.opensearch.security.securityconf.SecurityRoles; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.WildcardMatcher; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.ActionRequest; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.common.settings.Settings; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.resolver.IndexResolverReplacer; +import org.opensearch.security.securityconf.SecurityRoles; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.tasks.Task; public class ProtectedIndexAccessEvaluator { diff --git a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java index 93ea39af94..2d76c8fdb5 100644 --- a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java @@ -35,19 +35,19 @@ import java.util.List; import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.ActionRequest; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.common.settings.Settings; -import org.opensearch.tasks.Task; - import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.resolver.IndexResolverReplacer; import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; +import org.opensearch.tasks.Task; public class SecurityIndexAccessEvaluator { diff --git a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java index 9e1a1e976b..7edb155950 100644 --- a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java @@ -32,17 +32,17 @@ import java.util.List; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.common.settings.Settings; -import org.opensearch.security.configuration.ClusterInfoHolder; -import org.opensearch.tasks.Task; - import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.configuration.ClusterInfoHolder; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.SnapshotRestoreHelper; +import org.opensearch.tasks.Task; public class SnapshotRestoreEvaluator { diff --git a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java index 1ac27f6b37..5392d66e3d 100644 --- a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java @@ -32,8 +32,9 @@ import java.util.Set; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.ActionRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -43,7 +44,6 @@ import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.search.aggregations.AggregationBuilder; import org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder; - import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.SecurityRoles; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java index 8147a1e95c..af8adb4419 100644 --- a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java +++ b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java @@ -43,12 +43,12 @@ import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; -import org.opensearch.action.admin.indices.datastream.CreateDataStreamAction; -import org.opensearch.action.admin.indices.resolve.ResolveIndexAction; -import org.opensearch.security.OpenSearchSecurityPlugin; +import com.google.common.collect.ImmutableSet; import org.apache.commons.collections.keyvalue.MultiKey; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.IndicesRequest; @@ -58,7 +58,9 @@ import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; +import org.opensearch.action.admin.indices.datastream.CreateDataStreamAction; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; +import org.opensearch.action.admin.indices.resolve.ResolveIndexAction; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkShardRequest; import org.opensearch.action.delete.DeleteRequest; @@ -86,18 +88,15 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexNotFoundException; import org.opensearch.index.reindex.ReindexRequest; +import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.configuration.ClusterInfoHolder; import org.opensearch.security.securityconf.DynamicConfigModel; +import org.opensearch.security.support.SnapshotRestoreHelper; +import org.opensearch.security.support.WildcardMatcher; import org.opensearch.snapshots.SnapshotInfo; import org.opensearch.snapshots.SnapshotUtils; import org.opensearch.transport.RemoteClusterService; import org.opensearch.transport.TransportRequest; -import org.greenrobot.eventbus.Subscribe; - -import org.opensearch.security.support.SnapshotRestoreHelper; -import org.opensearch.security.support.WildcardMatcher; - -import com.google.common.collect.ImmutableSet; import static org.opensearch.cluster.metadata.IndexAbstraction.Type.ALIAS; diff --git a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java index f0c26cec27..b2578db183 100644 --- a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java @@ -30,14 +30,13 @@ package org.opensearch.security.rest; -import static org.opensearch.rest.RestRequest.Method.GET; -import static org.opensearch.rest.RestRequest.Method.POST; - import java.io.IOException; import java.util.List; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -50,10 +49,11 @@ import org.opensearch.rest.RestStatus; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.support.ConfigConstants; -import org.opensearch.threadpool.ThreadPool; import org.opensearch.security.user.User; -import com.google.common.collect.ImmutableList; +import org.opensearch.threadpool.ThreadPool; +import static org.opensearch.rest.RestRequest.Method.GET; +import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class DashboardsInfoAction extends BaseRestHandler { diff --git a/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java b/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java index 4e1ac87266..b6f71007f9 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java @@ -5,11 +5,20 @@ package org.opensearch.security.rest; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; + import com.google.common.collect.ImmutableList; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.rest.*; +import org.opensearch.rest.BaseRestHandler; +import org.opensearch.rest.BytesRestResponse; +import org.opensearch.rest.RestController; +import org.opensearch.rest.RestRequest; +import org.opensearch.rest.RestStatus; import org.opensearch.rest.action.RestActions.NodesResponseRestListener; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; @@ -20,10 +29,6 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - import static org.opensearch.rest.RestRequest.Method.PUT; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java b/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java index a423528e00..f7296ce849 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java @@ -30,12 +30,11 @@ package org.opensearch.security.rest; -import static org.opensearch.rest.RestRequest.Method.GET; -import static org.opensearch.rest.RestRequest.Method.POST; - import java.io.IOException; import java.util.List; +import com.google.common.collect.ImmutableList; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -45,10 +44,10 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; - import org.opensearch.security.auth.BackendRegistry; -import com.google.common.collect.ImmutableList; +import static org.opensearch.rest.RestRequest.Method.GET; +import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class SecurityHealthAction extends BaseRestHandler { diff --git a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java index 04a6b427fc..ecce9850bc 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java @@ -30,9 +30,6 @@ package org.opensearch.security.rest; -import static org.opensearch.rest.RestRequest.Method.GET; -import static org.opensearch.rest.RestRequest.Method.POST; - import java.io.IOException; import java.io.Serializable; import java.nio.charset.StandardCharsets; @@ -40,9 +37,11 @@ import java.util.List; import java.util.Set; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.util.RamUsageEstimator; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; @@ -59,8 +58,9 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import com.google.common.collect.ImmutableList; +import static org.opensearch.rest.RestRequest.Method.GET; +import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class SecurityInfoAction extends BaseRestHandler { diff --git a/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java b/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java index 13708ae9e3..a57448b33a 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java @@ -5,9 +5,15 @@ package org.opensearch.security.rest; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -25,11 +31,6 @@ import org.opensearch.security.support.WildcardMatcher; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; - import static org.opensearch.rest.RestRequest.Method.GET; import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java index da9a626714..f9c38f186f 100644 --- a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java @@ -30,22 +30,16 @@ package org.opensearch.security.rest; -import static org.opensearch.rest.RestRequest.Method.GET; -import static org.opensearch.rest.RestRequest.Method.POST; - import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.SortedMap; -import com.google.common.base.Strings; -import org.opensearch.security.configuration.ConfigurationRepository; -import org.opensearch.security.securityconf.DynamicConfigFactory; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.securityconf.RoleMappings; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.metadata.IndexAbstraction; import org.opensearch.cluster.service.ClusterService; @@ -59,12 +53,18 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.privileges.PrivilegesEvaluator; +import org.opensearch.security.securityconf.DynamicConfigFactory; +import org.opensearch.security.securityconf.RoleMappings; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import com.google.common.collect.ImmutableList; +import static org.opensearch.rest.RestRequest.Method.GET; +import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class TenantInfoAction extends BaseRestHandler { diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModel.java b/src/main/java/org/opensearch/security/securityconf/ConfigModel.java index c5b70cb7c6..613d85bfad 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModel.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModel.java @@ -34,7 +34,6 @@ import java.util.Set; import org.opensearch.common.transport.TransportAddress; - import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java index a7af70f77a..a9ba2d7142 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java @@ -35,8 +35,16 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Joiner; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.MultimapBuilder.SetMultimapBuilder; +import com.google.common.collect.SetMultimap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -55,13 +63,6 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; -import com.google.common.base.Joiner; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.MultimapBuilder.SetMultimapBuilder; -import com.google.common.collect.SetMultimap; import static org.opensearch.cluster.metadata.IndexAbstraction.Type.ALIAS; diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java index a496f520cc..aa64b421b2 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java @@ -35,8 +35,16 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import com.google.common.base.Joiner; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.MultimapBuilder.SetMultimapBuilder; +import com.google.common.collect.SetMultimap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -56,13 +64,6 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; -import com.google.common.base.Joiner; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.MultimapBuilder.SetMultimapBuilder; -import com.google.common.collect.SetMultimap; import static org.opensearch.cluster.metadata.IndexAbstraction.Type.ALIAS; diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java index 142fb411b5..93e4176eea 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java @@ -39,28 +39,27 @@ import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.securityconf.impl.NodesDn; -import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.opensearch.security.support.WildcardMatcher; +import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.ImmutableList; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableMap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.EventBusBuilder; + import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.auth.internal.InternalAuthenticationBackend; import org.opensearch.security.configuration.ClusterInfoHolder; import org.opensearch.security.configuration.ConfigurationChangeListener; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.configuration.StaticResourceException; -import org.opensearch.threadpool.ThreadPool; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.EventBusBuilder; - -import com.fasterxml.jackson.databind.JsonNode; -import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.NodesDn; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.opensearch.security.securityconf.impl.WhitelistingSettings; import org.opensearch.security.securityconf.impl.v6.ActionGroupsV6; import org.opensearch.security.securityconf.impl.v6.ConfigV6; import org.opensearch.security.securityconf.impl.v6.InternalUserV6; @@ -73,8 +72,8 @@ import org.opensearch.security.securityconf.impl.v7.RoleV7; import org.opensearch.security.securityconf.impl.v7.TenantV7; import org.opensearch.security.support.ConfigConstants; - -import com.google.common.collect.ImmutableMap; +import org.opensearch.security.support.WildcardMatcher; +import org.opensearch.threadpool.ThreadPool; public class DynamicConfigFactory implements Initializable, ConfigurationChangeListener { diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java index 64e0e260c6..e546f97c67 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java @@ -38,8 +38,9 @@ import java.util.Set; import java.util.SortedSet; -import org.apache.logging.log4j.Logger; +import com.google.common.collect.Multimap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.security.auth.AuthDomain; import org.opensearch.security.auth.AuthFailureListener; @@ -54,7 +55,6 @@ import org.opensearch.security.http.HTTPClientCertAuthenticator; import org.opensearch.security.http.HTTPProxyAuthenticator; import org.opensearch.security.http.proxy.HTTPExtendedProxyAuthenticator; -import com.google.common.collect.Multimap; public abstract class DynamicConfigModel { diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java index ec4286f3e9..b19642205e 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java @@ -43,9 +43,13 @@ import java.util.SortedSet; import java.util.TreeSet; +import com.google.common.base.Strings; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; + import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; - import org.opensearch.security.auth.AuthDomain; import org.opensearch.security.auth.AuthFailureListener; import org.opensearch.security.auth.AuthenticationBackend; @@ -60,10 +64,6 @@ import org.opensearch.security.securityconf.impl.v6.ConfigV6.Authz; import org.opensearch.security.securityconf.impl.v6.ConfigV6.AuthzDomain; import org.opensearch.security.support.ReflectionHelper; -import com.google.common.base.Strings; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; public class DynamicConfigModelV6 extends DynamicConfigModel { diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java index 66fcf9c4ec..394b0c451c 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java @@ -43,9 +43,13 @@ import java.util.SortedSet; import java.util.TreeSet; +import com.google.common.base.Strings; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; + import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; - import org.opensearch.security.auth.AuthDomain; import org.opensearch.security.auth.AuthFailureListener; import org.opensearch.security.auth.AuthenticationBackend; @@ -60,10 +64,6 @@ import org.opensearch.security.securityconf.impl.v7.ConfigV7.Authz; import org.opensearch.security.securityconf.impl.v7.ConfigV7.AuthzDomain; import org.opensearch.security.support.ReflectionHelper; -import com.google.common.base.Strings; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; public class DynamicConfigModelV7 extends DynamicConfigModel { diff --git a/src/main/java/org/opensearch/security/securityconf/Migration.java b/src/main/java/org/opensearch/security/securityconf/Migration.java index 363c14e94a..153cca3839 100644 --- a/src/main/java/org/opensearch/security/securityconf/Migration.java +++ b/src/main/java/org/opensearch/security/securityconf/Migration.java @@ -36,18 +36,25 @@ import java.util.Map.Entry; import java.util.Set; +import org.opensearch.common.Strings; +import org.opensearch.common.collect.Tuple; import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.Meta; import org.opensearch.security.securityconf.impl.NodesDn; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.opensearch.security.securityconf.impl.v6.*; -import org.opensearch.security.securityconf.impl.v7.*; -import org.opensearch.common.Strings; -import org.opensearch.common.collect.Tuple; -import org.opensearch.security.securityconf.impl.v6.*; -import org.opensearch.security.securityconf.impl.v7.*; +import org.opensearch.security.securityconf.impl.v6.ActionGroupsV6; +import org.opensearch.security.securityconf.impl.v6.ConfigV6; +import org.opensearch.security.securityconf.impl.v6.InternalUserV6; +import org.opensearch.security.securityconf.impl.v6.RoleMappingsV6; +import org.opensearch.security.securityconf.impl.v6.RoleV6; +import org.opensearch.security.securityconf.impl.v7.ActionGroupsV7; +import org.opensearch.security.securityconf.impl.v7.ConfigV7; +import org.opensearch.security.securityconf.impl.v7.InternalUserV7; +import org.opensearch.security.securityconf.impl.v7.RoleMappingsV7; +import org.opensearch.security.securityconf.impl.v7.RoleV7; +import org.opensearch.security.securityconf.impl.v7.TenantV7; public class Migration { diff --git a/src/main/java/org/opensearch/security/securityconf/NodesDnModel.java b/src/main/java/org/opensearch/security/securityconf/NodesDnModel.java index e5cf8cea93..aedcc0703b 100644 --- a/src/main/java/org/opensearch/security/securityconf/NodesDnModel.java +++ b/src/main/java/org/opensearch/security/securityconf/NodesDnModel.java @@ -15,10 +15,10 @@ package org.opensearch.security.securityconf; -import org.opensearch.security.support.WildcardMatcher; - import java.util.Map; +import org.opensearch.security.support.WildcardMatcher; + public abstract class NodesDnModel { public abstract Map getNodesDn(); } diff --git a/src/main/java/org/opensearch/security/securityconf/impl/NodesDn.java b/src/main/java/org/opensearch/security/securityconf/impl/NodesDn.java index 372a0daf0d..bb30484d9c 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/NodesDn.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/NodesDn.java @@ -15,12 +15,12 @@ package org.opensearch.security.securityconf.impl; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + public class NodesDn { @JsonProperty(value = "nodes_dn") private List nodesDn; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java b/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java index c634925838..91f9e1b768 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java @@ -37,18 +37,18 @@ import java.util.Map; import java.util.Map.Entry; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; + import org.opensearch.ExceptionsHelper; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.NonValidatingObjectMapper; import org.opensearch.security.securityconf.Hashed; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/WhitelistingSettings.java b/src/main/java/org/opensearch/security/securityconf/impl/WhitelistingSettings.java index 37ed930a40..10fac0e6cc 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/WhitelistingSettings.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/WhitelistingSettings.java @@ -15,15 +15,16 @@ package org.opensearch.security.securityconf.impl; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.opensearch.client.node.NodeClient; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; public class WhitelistingSettings { private boolean enabled; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v6/ActionGroupsV6.java b/src/main/java/org/opensearch/security/securityconf/impl/v6/ActionGroupsV6.java index 3fa7530f6d..0032745d23 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v6/ActionGroupsV6.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v6/ActionGroupsV6.java @@ -34,6 +34,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnore; + import org.opensearch.security.securityconf.Hideable; public class ActionGroupsV6 implements Hideable { diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v6/ConfigV6.java b/src/main/java/org/opensearch/security/securityconf/impl/v6/ConfigV6.java index 58278ab3fa..7274d0a799 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v6/ConfigV6.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v6/ConfigV6.java @@ -42,6 +42,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; + import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auth.internal.InternalAuthenticationBackend; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v6/InternalUserV6.java b/src/main/java/org/opensearch/security/securityconf/impl/v6/InternalUserV6.java index 26332544da..469ee86709 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v6/InternalUserV6.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v6/InternalUserV6.java @@ -36,6 +36,7 @@ import java.util.Map; import com.fasterxml.jackson.annotation.JsonIgnore; + import org.opensearch.security.securityconf.Hashed; import org.opensearch.security.securityconf.Hideable; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleMappingsV6.java b/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleMappingsV6.java index 1f224f3b0a..62c0756730 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleMappingsV6.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleMappingsV6.java @@ -34,10 +34,11 @@ import java.util.Collections; import java.util.List; -import org.opensearch.security.securityconf.RoleMappings; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import org.opensearch.security.securityconf.Hideable; +import org.opensearch.security.securityconf.RoleMappings; public class RoleMappingsV6 extends RoleMappings implements Hideable { diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleV6.java b/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleV6.java index d8a70abfe1..3d7af06f38 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleV6.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v6/RoleV6.java @@ -39,6 +39,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; + import org.opensearch.security.securityconf.Hideable; public class RoleV6 implements Hideable { diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v7/ActionGroupsV7.java b/src/main/java/org/opensearch/security/securityconf/impl/v7/ActionGroupsV7.java index 23f00d7c8e..3f5bbd75bd 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v7/ActionGroupsV7.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v7/ActionGroupsV7.java @@ -35,6 +35,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; + import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.StaticDefinable; import org.opensearch.security.securityconf.impl.v6.ActionGroupsV6; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v7/ConfigV7.java b/src/main/java/org/opensearch/security/securityconf/impl/v7/ConfigV7.java index c4cad1732d..0f7c3753f7 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v7/ConfigV7.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v7/ConfigV7.java @@ -42,6 +42,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; + import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auth.internal.InternalAuthenticationBackend; import org.opensearch.security.securityconf.impl.v6.ConfigV6; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v7/InternalUserV7.java b/src/main/java/org/opensearch/security/securityconf/impl/v7/InternalUserV7.java index cf920ec4d7..4d601081c3 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v7/InternalUserV7.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v7/InternalUserV7.java @@ -37,6 +37,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; + import org.opensearch.security.securityconf.Hashed; import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.StaticDefinable; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v7/RoleV7.java b/src/main/java/org/opensearch/security/securityconf/impl/v7/RoleV7.java index 9168bd58c3..97957e556a 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v7/RoleV7.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v7/RoleV7.java @@ -40,6 +40,7 @@ import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonProperty; + import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.StaticDefinable; import org.opensearch.security.securityconf.impl.v6.RoleV6; diff --git a/src/main/java/org/opensearch/security/securityconf/impl/v7/TenantV7.java b/src/main/java/org/opensearch/security/securityconf/impl/v7/TenantV7.java index db03091f79..742e18d920 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/v7/TenantV7.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/v7/TenantV7.java @@ -32,6 +32,7 @@ package org.opensearch.security.securityconf.impl.v7; import com.fasterxml.jackson.annotation.JsonProperty; + import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.StaticDefinable; diff --git a/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java b/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java index 0934081573..9b0befabd0 100644 --- a/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java +++ b/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java @@ -15,8 +15,9 @@ package org.opensearch.security.setting; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; diff --git a/src/main/java/org/opensearch/security/setting/TransportPassiveAuthSetting.java b/src/main/java/org/opensearch/security/setting/TransportPassiveAuthSetting.java index 455ff50121..6de78eda51 100644 --- a/src/main/java/org/opensearch/security/setting/TransportPassiveAuthSetting.java +++ b/src/main/java/org/opensearch/security/setting/TransportPassiveAuthSetting.java @@ -15,9 +15,9 @@ package org.opensearch.security.setting; -import org.opensearch.security.support.ConfigConstants; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; public class TransportPassiveAuthSetting extends OpensearchDynamicSetting { diff --git a/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java index c84e8a05de..d95797b8b7 100644 --- a/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java @@ -17,17 +17,9 @@ package org.opensearch.security.ssl; -import io.netty.buffer.PooledByteBufAllocator; -import io.netty.handler.ssl.ApplicationProtocolConfig; -import io.netty.handler.ssl.ClientAuth; -import io.netty.handler.ssl.OpenSsl; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.SslProvider; - import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.File; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; @@ -57,18 +49,16 @@ import javax.net.ssl.SSLException; import javax.net.ssl.SSLParameters; -import org.opensearch.security.ssl.util.CertFileProps; -import org.opensearch.security.ssl.util.CertFromFile; -import org.opensearch.security.ssl.util.CertFromKeystore; -import org.opensearch.security.ssl.util.CertFromTruststore; -import org.opensearch.security.ssl.util.ExceptionUtils; -import org.opensearch.security.ssl.util.KeystoreProps; -import org.opensearch.security.ssl.util.SSLConfigConstants; - +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.handler.ssl.ApplicationProtocolConfig; +import io.netty.handler.ssl.ClientAuth; +import io.netty.handler.ssl.OpenSsl; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; +import io.netty.handler.ssl.SslProvider; import io.netty.util.internal.PlatformDependent; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; - +import org.apache.logging.log4j.Logger; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.ASN1Primitive; @@ -81,6 +71,13 @@ import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; +import org.opensearch.security.ssl.util.CertFileProps; +import org.opensearch.security.ssl.util.CertFromFile; +import org.opensearch.security.ssl.util.CertFromKeystore; +import org.opensearch.security.ssl.util.CertFromTruststore; +import org.opensearch.security.ssl.util.ExceptionUtils; +import org.opensearch.security.ssl.util.KeystoreProps; +import org.opensearch.security.ssl.util.SSLConfigConstants; public class DefaultSecurityKeyStore implements SecurityKeyStore { diff --git a/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java index a8fa29c4cd..3fbbab69d6 100644 --- a/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java @@ -32,7 +32,6 @@ import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; - import org.opensearch.security.ssl.util.SSLConfigConstants; public class ExternalSecurityKeyStore implements SecurityKeyStore { diff --git a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java index b1042b3fd2..15e93ae177 100644 --- a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java +++ b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java @@ -17,15 +17,6 @@ package org.opensearch.security.ssl; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.NonValidatingObjectMapper; -import org.opensearch.security.ssl.http.netty.SecuritySSLNettyHttpServerTransport; -import org.opensearch.security.ssl.transport.SSLConfig; -import org.opensearch.security.ssl.transport.SecuritySSLNettyTransport; -import com.fasterxml.jackson.databind.InjectableValues; -import io.netty.handler.ssl.OpenSsl; -import io.netty.util.internal.PlatformDependent; - import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; @@ -39,8 +30,12 @@ import java.util.function.Function; import java.util.function.Supplier; -import org.apache.logging.log4j.Logger; +import com.fasterxml.jackson.databind.InjectableValues; +import io.netty.handler.ssl.OpenSsl; +import io.netty.util.internal.PlatformDependent; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.SpecialPermission; import org.opensearch.Version; @@ -74,8 +69,16 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestHandler; import org.opensearch.script.ScriptService; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.NonValidatingObjectMapper; +import org.opensearch.security.ssl.http.netty.SecuritySSLNettyHttpServerTransport; +import org.opensearch.security.ssl.http.netty.ValidatingDispatcher; import org.opensearch.security.ssl.rest.SecuritySSLInfoAction; -import org.opensearch.security.ssl.transport.*; +import org.opensearch.security.ssl.transport.DefaultPrincipalExtractor; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.ssl.transport.SSLConfig; +import org.opensearch.security.ssl.transport.SecuritySSLNettyTransport; +import org.opensearch.security.ssl.transport.SecuritySSLTransportInterceptor; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; @@ -83,10 +86,6 @@ import org.opensearch.transport.TransportInterceptor; import org.opensearch.watcher.ResourceWatcherService; -import org.opensearch.security.ssl.http.netty.ValidatingDispatcher; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.ssl.transport.SecuritySSLTransportInterceptor; - //For ES5 this class has only effect when SSL only plugin is installed public class OpenSearchSecuritySSLPlugin extends Plugin implements SystemIndexPlugin, NetworkPlugin { diff --git a/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java index 1171520462..a14e8e7df1 100644 --- a/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java @@ -17,9 +17,10 @@ package org.opensearch.security.ssl; +import java.security.cert.X509Certificate; + import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; -import java.security.cert.X509Certificate; public interface SecurityKeyStore { diff --git a/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java b/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java index 197c587f5e..5e604beb87 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java @@ -17,8 +17,13 @@ package org.opensearch.security.ssl.http.netty; -import org.apache.logging.log4j.Logger; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.handler.codec.DecoderException; +import io.netty.handler.ssl.SslHandler; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -32,11 +37,6 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.ssl.SslHandler; - public class SecuritySSLNettyHttpServerTransport extends Netty4HttpServerTransport { private static final Logger logger = LogManager.getLogger(SecuritySSLNettyHttpServerTransport.class); diff --git a/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java b/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java index c4129c08cf..66976a930b 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java @@ -21,18 +21,18 @@ import javax.net.ssl.SSLPeerUnverifiedException; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.ExceptionsHelper; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.http.HttpServerTransport.Dispatcher; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; - import org.opensearch.security.ssl.SslExceptionHandler; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.ssl.util.SSLRequestHelper; diff --git a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java index 6e77dff92b..915f8a03e2 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java @@ -15,13 +15,18 @@ package org.opensearch.security.ssl.rest; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.ssl.SecurityKeyStore; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.user.User; +import java.io.IOException; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -33,17 +38,12 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.security.cert.CertificateParsingException; -import java.security.cert.X509Certificate; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - /** * Rest API action to get SSL certificate information related to http and transport encryption. diff --git a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java index b20e4084f7..8127960efc 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java @@ -17,8 +17,6 @@ package org.opensearch.security.ssl.rest; -import io.netty.handler.ssl.OpenSsl; - import java.io.IOException; import java.nio.file.Path; import java.security.cert.X509Certificate; @@ -27,8 +25,10 @@ import java.util.List; import java.util.stream.Collectors; -import org.apache.logging.log4j.Logger; +import io.netty.handler.ssl.OpenSsl; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -39,7 +39,6 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; - import org.opensearch.security.ssl.SecurityKeyStore; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.ssl.util.SSLRequestHelper; diff --git a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLReloadCertsAction.java b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLReloadCertsAction.java index 76527ed31a..6196ca0073 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLReloadCertsAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLReloadCertsAction.java @@ -15,10 +15,10 @@ package org.opensearch.security.ssl.rest; -import org.opensearch.security.configuration.AdminDNs; -import org.opensearch.security.ssl.SecurityKeyStore; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.user.User; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -29,12 +29,12 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestStatus; +import org.opensearch.security.configuration.AdminDNs; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.Collections; -import java.util.List; - import static org.opensearch.rest.RestRequest.Method.PUT; diff --git a/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java b/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java index 4a32226f87..fcb721946b 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java @@ -30,8 +30,9 @@ import javax.naming.ldap.Rdn; import javax.security.auth.x500.X500Principal; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.SpecialPermission; public class DefaultPrincipalExtractor implements PrincipalExtractor { diff --git a/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java b/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java index 71a9ef42cc..ace78eb742 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java @@ -15,9 +15,11 @@ package org.opensearch.security.ssl.transport; -import org.opensearch.security.ssl.SecurityKeyStore; -import org.opensearch.security.ssl.util.SSLConnectionTestUtil; -import org.opensearch.security.ssl.util.TLSUtil; +import java.nio.charset.StandardCharsets; +import java.util.List; + +import javax.net.ssl.SSLException; + import com.google.common.annotations.VisibleForTesting; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -26,12 +28,12 @@ import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.ssl.SslHandler; -import java.nio.charset.StandardCharsets; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -import javax.net.ssl.SSLException; -import java.util.List; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.ssl.util.SSLConnectionTestUtil; +import org.opensearch.security.ssl.util.TLSUtil; /** * Modifies the current pipeline dynamically to enable TLS diff --git a/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java b/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java index c9722ec640..6e89c7121b 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java @@ -15,12 +15,12 @@ package org.opensearch.security.ssl.transport; -import org.opensearch.security.support.ConfigConstants; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.ClusterSettings; -import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.SecuritySettings; public class SSLConfig { diff --git a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java index 27b3174c95..465c5c3a8d 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java @@ -32,8 +32,6 @@ package org.opensearch.security.ssl.transport; -import org.opensearch.security.ssl.util.SSLConnectionTestResult; -import org.opensearch.security.ssl.util.SSLConnectionTestUtil; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.security.AccessController; @@ -42,8 +40,16 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; -import org.apache.logging.log4j.Logger; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.handler.codec.DecoderException; +import io.netty.handler.ssl.SslHandler; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; @@ -52,23 +58,16 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.PageCacheRecycler; import org.opensearch.indices.breaker.CircuitBreakerService; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.ssl.SslExceptionHandler; +import org.opensearch.security.ssl.util.SSLConfigConstants; +import org.opensearch.security.ssl.util.SSLConnectionTestResult; +import org.opensearch.security.ssl.util.SSLConnectionTestUtil; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; import org.opensearch.transport.TcpChannel; import org.opensearch.transport.netty4.Netty4Transport; -import org.opensearch.security.ssl.SecurityKeyStore; -import org.opensearch.security.ssl.SslExceptionHandler; -import org.opensearch.security.ssl.util.SSLConfigConstants; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; -import io.netty.channel.ChannelPromise; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.ssl.SslHandler; - public class SecuritySSLNettyTransport extends Netty4Transport { private static final Logger logger = LogManager.getLogger(SecuritySSLNettyTransport.class); diff --git a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java index b056a88d75..925f5cf0e9 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java @@ -24,12 +24,17 @@ import javax.net.ssl.SSLPeerUnverifiedException; -import org.opensearch.security.support.ConfigConstants; -import org.apache.logging.log4j.Logger; +import io.netty.handler.ssl.SslHandler; import org.apache.logging.log4j.LogManager; -import org.opensearch.OpenSearchException; +import org.apache.logging.log4j.Logger; + import org.opensearch.ExceptionsHelper; +import org.opensearch.OpenSearchException; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.security.ssl.SslExceptionHandler; +import org.opensearch.security.ssl.util.ExceptionUtils; +import org.opensearch.security.ssl.util.SSLRequestHelper; +import org.opensearch.security.support.ConfigConstants; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TaskTransportChannel; @@ -40,12 +45,6 @@ import org.opensearch.transport.TransportRequestHandler; import org.opensearch.transport.netty4.Netty4TcpChannel; -import org.opensearch.security.ssl.SslExceptionHandler; -import org.opensearch.security.ssl.util.ExceptionUtils; -import org.opensearch.security.ssl.util.SSLRequestHelper; - -import io.netty.handler.ssl.SslHandler; - public class SecuritySSLRequestHandler implements TransportRequestHandler { diff --git a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java index a268a40b8f..165662d429 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java @@ -17,16 +17,16 @@ package org.opensearch.security.ssl.transport; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.settings.Settings; +import org.opensearch.security.ssl.SslExceptionHandler; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportInterceptor; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportRequestHandler; -import org.opensearch.security.ssl.SslExceptionHandler; - public final class SecuritySSLTransportInterceptor implements TransportInterceptor { protected final Logger log = LogManager.getLogger(this.getClass()); diff --git a/src/main/java/org/opensearch/security/ssl/util/CertFromFile.java b/src/main/java/org/opensearch/security/ssl/util/CertFromFile.java index 17cba8d252..7383ae8290 100644 --- a/src/main/java/org/opensearch/security/ssl/util/CertFromFile.java +++ b/src/main/java/org/opensearch/security/ssl/util/CertFromFile.java @@ -1,10 +1,10 @@ package org.opensearch.security.ssl.util; -import org.opensearch.security.support.PemKeyReader; - import java.io.File; import java.security.cert.X509Certificate; +import org.opensearch.security.support.PemKeyReader; + public class CertFromFile { private final CertFileProps clientCertProps; private final CertFileProps serverCertProps; diff --git a/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java b/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java index a9ee6ea4d2..4591ace69c 100644 --- a/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java +++ b/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java @@ -1,8 +1,5 @@ package org.opensearch.security.ssl.util; -import org.apache.commons.lang3.ArrayUtils; -import org.opensearch.OpenSearchException; - import java.io.IOException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -12,6 +9,10 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import org.apache.commons.lang3.ArrayUtils; + +import org.opensearch.OpenSearchException; + public class CertFromKeystore { private final KeystoreProps keystoreProps; diff --git a/src/main/java/org/opensearch/security/ssl/util/CertFromTruststore.java b/src/main/java/org/opensearch/security/ssl/util/CertFromTruststore.java index 69b386c120..8ca7e500a7 100644 --- a/src/main/java/org/opensearch/security/ssl/util/CertFromTruststore.java +++ b/src/main/java/org/opensearch/security/ssl/util/CertFromTruststore.java @@ -1,7 +1,5 @@ package org.opensearch.security.ssl.util; -import org.opensearch.OpenSearchException; - import java.io.IOException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -9,6 +7,8 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import org.opensearch.OpenSearchException; + public class CertFromTruststore { private final KeystoreProps keystoreProps; diff --git a/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java b/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java index d7c75118b5..cb693bff08 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java @@ -31,8 +31,9 @@ import java.util.Enumeration; import java.util.List; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.Strings; public class SSLCertificateHelper { diff --git a/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java b/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java index b7d0bb2031..a02b323d79 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java @@ -15,7 +15,6 @@ package org.opensearch.security.ssl.util; -import com.google.common.annotations.VisibleForTesting; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -23,8 +22,10 @@ import java.io.OutputStreamWriter; import java.net.Socket; import java.nio.charset.StandardCharsets; -import org.apache.logging.log4j.Logger; + +import com.google.common.annotations.VisibleForTesting; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Utility class to test if the server supports SSL connections. diff --git a/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java b/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java index 26d35e3dfb..97980b4a44 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java @@ -17,8 +17,6 @@ package org.opensearch.security.ssl.util; -import io.netty.handler.ssl.SslHandler; - import java.io.File; import java.io.FileInputStream; import java.nio.file.Path; @@ -38,8 +36,10 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; -import org.apache.logging.log4j.Logger; +import io.netty.handler.ssl.SslHandler; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -47,7 +47,6 @@ import org.opensearch.env.Environment; import org.opensearch.http.netty4.Netty4HttpChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.ssl.transport.PrincipalExtractor.Type; diff --git a/src/main/java/org/opensearch/security/ssl/util/TLSUtil.java b/src/main/java/org/opensearch/security/ssl/util/TLSUtil.java index c843569c23..4b1a03f523 100644 --- a/src/main/java/org/opensearch/security/ssl/util/TLSUtil.java +++ b/src/main/java/org/opensearch/security/ssl/util/TLSUtil.java @@ -14,10 +14,10 @@ */ package org.opensearch.security.ssl.util; -import io.netty.buffer.ByteBuf; - import java.nio.ByteOrder; +import io.netty.buffer.ByteBuf; + public class TLSUtil { diff --git a/src/main/java/org/opensearch/security/support/Base64Helper.java b/src/main/java/org/opensearch/security/support/Base64Helper.java index d7dfa01711..67aecad164 100644 --- a/src/main/java/org/opensearch/security/support/Base64Helper.java +++ b/src/main/java/org/opensearch/security/support/Base64Helper.java @@ -30,12 +30,6 @@ package org.opensearch.security.support; -import com.amazon.dlic.auth.ldap.LdapUser; -import org.ldaptive.AbstractLdapBean; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.SearchEntry; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -58,16 +52,21 @@ import java.util.Set; import java.util.regex.Pattern; -import org.opensearch.OpenSearchException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.Strings; - -import org.opensearch.security.user.User; - import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.io.BaseEncoding; +import org.ldaptive.AbstractLdapBean; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.SearchEntry; + +import com.amazon.dlic.auth.ldap.LdapUser; + +import org.opensearch.OpenSearchException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.Strings; +import org.opensearch.security.user.User; public class Base64Helper { diff --git a/src/main/java/org/opensearch/security/support/ConfigConstants.java b/src/main/java/org/opensearch/security/support/ConfigConstants.java index 587f0f1ff7..81cdfecf45 100644 --- a/src/main/java/org/opensearch/security/support/ConfigConstants.java +++ b/src/main/java/org/opensearch/security/support/ConfigConstants.java @@ -30,10 +30,6 @@ package org.opensearch.security.support; -import org.opensearch.security.auditlog.impl.AuditCategory; - -import org.opensearch.common.settings.Settings; - import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -43,6 +39,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.auditlog.impl.AuditCategory; + public class ConfigConstants { diff --git a/src/main/java/org/opensearch/security/support/ConfigHelper.java b/src/main/java/org/opensearch/security/support/ConfigHelper.java index 0bcb8fefb8..8524aab7d8 100644 --- a/src/main/java/org/opensearch/security/support/ConfigHelper.java +++ b/src/main/java/org/opensearch/security/support/ConfigHelper.java @@ -36,9 +36,9 @@ import java.io.Reader; import java.io.StringReader; -import org.opensearch.security.securityconf.impl.Meta; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.DocWriteRequest.OpType; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; @@ -49,11 +49,11 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; - +import org.opensearch.index.engine.VersionConflictEngineException; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.Meta; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.opensearch.index.engine.VersionConflictEngineException; import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; diff --git a/src/main/java/org/opensearch/security/support/HTTPHelper.java b/src/main/java/org/opensearch/security/support/HTTPHelper.java index 0e08d86764..a4656d7ef9 100644 --- a/src/main/java/org/opensearch/security/support/HTTPHelper.java +++ b/src/main/java/org/opensearch/security/support/HTTPHelper.java @@ -36,8 +36,8 @@ import java.util.Map; import org.apache.logging.log4j.Logger; -import org.opensearch.rest.RestRequest; +import org.opensearch.rest.RestRequest; import org.opensearch.security.user.AuthCredentials; public class HTTPHelper { diff --git a/src/main/java/org/opensearch/security/support/HeaderHelper.java b/src/main/java/org/opensearch/security/support/HeaderHelper.java index 259493cc9c..d96663b779 100644 --- a/src/main/java/org/opensearch/security/support/HeaderHelper.java +++ b/src/main/java/org/opensearch/security/support/HeaderHelper.java @@ -33,10 +33,10 @@ import java.io.Serializable; import java.util.Map; -import org.opensearch.common.util.concurrent.ThreadContext; - import com.google.common.base.Strings; +import org.opensearch.common.util.concurrent.ThreadContext; + public class HeaderHelper { public static boolean isInterClusterRequest(final ThreadContext context) { diff --git a/src/main/java/org/opensearch/security/support/PemKeyReader.java b/src/main/java/org/opensearch/security/support/PemKeyReader.java index ccaa7d61be..dc0f805edf 100644 --- a/src/main/java/org/opensearch/security/support/PemKeyReader.java +++ b/src/main/java/org/opensearch/security/support/PemKeyReader.java @@ -67,9 +67,10 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.bouncycastle.util.encoders.Base64; + import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; diff --git a/src/main/java/org/opensearch/security/support/ReflectionHelper.java b/src/main/java/org/opensearch/security/support/ReflectionHelper.java index c4120bd0dc..0815037753 100644 --- a/src/main/java/org/opensearch/security/support/ReflectionHelper.java +++ b/src/main/java/org/opensearch/security/support/ReflectionHelper.java @@ -39,11 +39,11 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; - import org.opensearch.security.ssl.transport.DefaultPrincipalExtractor; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.transport.DefaultInterClusterRequestEvaluator; diff --git a/src/main/java/org/opensearch/security/support/SecurityJsonNode.java b/src/main/java/org/opensearch/security/support/SecurityJsonNode.java index b8485b693b..472ab2bb86 100644 --- a/src/main/java/org/opensearch/security/support/SecurityJsonNode.java +++ b/src/main/java/org/opensearch/security/support/SecurityJsonNode.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeType; + import org.opensearch.security.DefaultObjectMapper; public final class SecurityJsonNode { diff --git a/src/main/java/org/opensearch/security/support/SecurityUtils.java b/src/main/java/org/opensearch/security/support/SecurityUtils.java index 2da1d0e252..c949d5668f 100644 --- a/src/main/java/org/opensearch/security/support/SecurityUtils.java +++ b/src/main/java/org/opensearch/security/support/SecurityUtils.java @@ -41,10 +41,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.common.settings.Settings; +import org.apache.logging.log4j.Logger; +import org.opensearch.common.settings.Settings; import org.opensearch.security.tools.Hasher; public final class SecurityUtils { diff --git a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java index cd3a72c329..4a3e0f3e51 100644 --- a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java +++ b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java @@ -35,14 +35,15 @@ import java.util.List; import java.util.Objects; -import org.opensearch.security.OpenSearchSecurityPlugin; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.SpecialPermission; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.repositories.RepositoriesService; import org.opensearch.repositories.Repository; +import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.snapshots.SnapshotId; import org.opensearch.snapshots.SnapshotInfo; import org.opensearch.snapshots.SnapshotUtils; diff --git a/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java b/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java index 6e21c1834f..7942541f1f 100644 --- a/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java +++ b/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java @@ -15,8 +15,12 @@ package org.opensearch.security.tools; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.config.AuditConfig; +import java.io.File; +import java.io.FileOutputStream; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Map; + import com.google.common.collect.ImmutableMap; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; @@ -24,16 +28,13 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; + import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; - -import java.io.File; -import java.io.FileOutputStream; -import java.nio.file.Paths; -import java.util.Collections; -import java.util.Map; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; public class AuditConfigMigrater { diff --git a/src/main/java/org/opensearch/security/tools/Migrater.java b/src/main/java/org/opensearch/security/tools/Migrater.java index 4bc8d5673c..686644f59c 100644 --- a/src/main/java/org/opensearch/security/tools/Migrater.java +++ b/src/main/java/org/opensearch/security/tools/Migrater.java @@ -19,23 +19,23 @@ import java.io.File; -import org.opensearch.security.securityconf.impl.NodesDn; -import org.opensearch.security.support.ConfigHelper; +import com.google.common.io.Files; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; -import org.opensearch.common.collect.Tuple; +import org.opensearch.common.collect.Tuple; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.securityconf.Migration; import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.securityconf.impl.NodesDn; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.securityconf.impl.v7.RoleV7; import org.opensearch.security.securityconf.impl.v7.TenantV7; -import com.google.common.io.Files; +import org.opensearch.security.support.ConfigHelper; public class Migrater { diff --git a/src/main/java/org/opensearch/security/tools/SecurityAdmin.java b/src/main/java/org/opensearch/security/tools/SecurityAdmin.java index 59079028db..2b5f1c0043 100644 --- a/src/main/java/org/opensearch/security/tools/SecurityAdmin.java +++ b/src/main/java/org/opensearch/security/tools/SecurityAdmin.java @@ -30,6 +30,34 @@ package org.opensearch.security.tools; +import java.io.ByteArrayInputStream; +import java.io.Console; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.Writer; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; + import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Charsets; @@ -51,6 +79,7 @@ import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; + import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchStatusException; @@ -58,10 +87,7 @@ import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; -import org.opensearch.client.indices.CreateIndexRequest; import org.opensearch.action.admin.indices.delete.DeleteIndexRequest; -import org.opensearch.client.indices.GetIndexRequest; -import org.opensearch.client.indices.GetIndexRequest.Feature; import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; @@ -74,13 +100,15 @@ import org.opensearch.client.RestClient; import org.opensearch.client.RestClientBuilder; import org.opensearch.client.RestHighLevelClient; +import org.opensearch.client.indices.CreateIndexRequest; +import org.opensearch.client.indices.GetIndexRequest; +import org.opensearch.client.indices.GetIndexRequest.Feature; import org.opensearch.client.indices.GetIndexResponse; import org.opensearch.client.transport.NoNodeAvailableException; import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; -import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.NamedXContentRegistry; @@ -112,33 +140,6 @@ import org.opensearch.security.support.PemKeyReader; import org.opensearch.security.support.SecurityJsonNode; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import java.io.ByteArrayInputStream; -import java.io.Console; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.Writer; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; import static org.opensearch.security.support.SecurityUtils.replaceEnvVars; diff --git a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java index feddf3d83b..6896046a9a 100644 --- a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java +++ b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java @@ -39,17 +39,17 @@ import java.util.List; import java.util.Map; -import org.opensearch.security.securityconf.DynamicConfigFactory; -import org.opensearch.security.securityconf.NodesDnModel; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.greenrobot.eventbus.Subscribe; + import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; -import org.opensearch.transport.TransportRequest; - +import org.opensearch.security.securityconf.DynamicConfigFactory; +import org.opensearch.security.securityconf.NodesDnModel; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; -import org.greenrobot.eventbus.Subscribe; +import org.opensearch.transport.TransportRequest; public final class DefaultInterClusterRequestEvaluator implements InterClusterRequestEvaluator { diff --git a/src/main/java/org/opensearch/security/transport/OIDClusterRequestEvaluator.java b/src/main/java/org/opensearch/security/transport/OIDClusterRequestEvaluator.java index e646f73b93..6fa1b584e6 100644 --- a/src/main/java/org/opensearch/security/transport/OIDClusterRequestEvaluator.java +++ b/src/main/java/org/opensearch/security/transport/OIDClusterRequestEvaluator.java @@ -34,9 +34,8 @@ import java.util.Arrays; import org.opensearch.common.settings.Settings; -import org.opensearch.transport.TransportRequest; - import org.opensearch.security.support.ConfigConstants; +import org.opensearch.transport.TransportRequest; /** * Implementation to evaluate a certificate extension with a given OID diff --git a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java index e9ac5aea54..8ae529db28 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java +++ b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java @@ -37,10 +37,11 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.opensearch.security.OpenSearchSecurityPlugin; +import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.opensearch.action.get.GetRequest; @@ -51,8 +52,17 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.security.OpenSearchSecurityPlugin; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.AuditLog.Origin; +import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.configuration.ClusterInfoHolder; +import org.opensearch.security.ssl.SslExceptionHandler; import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.ssl.transport.SSLConfig; +import org.opensearch.security.support.Base64Helper; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.Transport.Connection; import org.opensearch.transport.TransportException; @@ -63,18 +73,6 @@ import org.opensearch.transport.TransportResponse; import org.opensearch.transport.TransportResponseHandler; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.auditlog.AuditLog.Origin; -import org.opensearch.security.auth.BackendRegistry; -import org.opensearch.security.ssl.SslExceptionHandler; -import org.opensearch.security.support.Base64Helper; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.user.User; - -import org.opensearch.security.ssl.transport.SSLConfig; - -import com.google.common.collect.Maps; - import static org.opensearch.security.OpenSearchSecurityPlugin.isActionTraceEnabled; public class SecurityInterceptor { diff --git a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java index 2f7888f862..a2c32651ad 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java +++ b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java @@ -36,7 +36,8 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.opensearch.security.ssl.transport.SecuritySSLRequestHandler; +import com.google.common.base.Strings; + import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.bulk.BulkShardRequest; @@ -45,24 +46,22 @@ import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.search.internal.ShardSearchRequest; -import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.security.ssl.util.ExceptionUtils; -import org.opensearch.tasks.Task; -import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.TransportChannel; -import org.opensearch.transport.TransportRequest; -import org.opensearch.transport.TransportRequestHandler; - import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; import org.opensearch.security.ssl.SslExceptionHandler; +import org.opensearch.security.ssl.transport.PrincipalExtractor; +import org.opensearch.security.ssl.transport.SSLConfig; +import org.opensearch.security.ssl.transport.SecuritySSLRequestHandler; +import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.support.Base64Helper; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; import org.opensearch.security.user.User; -import org.opensearch.security.ssl.transport.SSLConfig; - -import com.google.common.base.Strings; +import org.opensearch.tasks.Task; +import org.opensearch.threadpool.ThreadPool; +import org.opensearch.transport.TransportChannel; +import org.opensearch.transport.TransportRequest; +import org.opensearch.transport.TransportRequestHandler; import static org.opensearch.security.OpenSearchSecurityPlugin.isActionTraceEnabled; diff --git a/src/main/java/org/opensearch/security/user/User.java b/src/main/java/org/opensearch/security/user/User.java index a1e2be5614..7185f60ad2 100644 --- a/src/main/java/org/opensearch/security/user/User.java +++ b/src/main/java/org/opensearch/security/user/User.java @@ -40,12 +40,12 @@ import java.util.Map; import java.util.Set; +import com.google.common.collect.Lists; + import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; -import com.google.common.collect.Lists; - /** * A authenticated user and attributes associated to them (like roles, tenant, custom attributes) *

diff --git a/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java b/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java index 9f73f35b9b..37a9817b34 100644 --- a/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java +++ b/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java @@ -21,13 +21,12 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalNotification; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class HeapBasedRateTracker implements RateTracker { diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticatorTest.java b/src/test/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticatorTest.java index 4a22f62525..5e16b2e122 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticatorTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/HTTPJwtAuthenticatorTest.java @@ -15,10 +15,6 @@ package com.amazon.dlic.auth.http.jwt; -import io.jsonwebtoken.JwtParser; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - import java.nio.charset.StandardCharsets; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -30,18 +26,19 @@ import java.util.HashMap; import java.util.Map; - -import org.opensearch.common.settings.Settings; - +import com.google.common.io.BaseEncoding; +import io.jsonwebtoken.JwtParser; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; import org.apache.http.HttpHeaders; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import org.mockito.internal.util.reflection.FieldSetter; +import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; -import com.google.common.io.BaseEncoding; public class HTTPJwtAuthenticatorTest { diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticatorTest.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticatorTest.java index 32c2bd4ecb..2e1da49ba9 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticatorTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticatorTest.java @@ -17,15 +17,15 @@ import java.util.HashMap; -import org.opensearch.common.settings.Settings; +import com.google.common.collect.ImmutableMap; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; -import com.google.common.collect.ImmutableMap; public class HTTPJwtKeyByOpenIdConnectAuthenticatorTest { diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetrieverTest.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetrieverTest.java index 0a165e6385..843fee4233 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetrieverTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/KeySetRetrieverTest.java @@ -24,6 +24,7 @@ import java.security.cert.X509Certificate; import java.util.Map; +import com.google.common.hash.Hashing; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; @@ -39,9 +40,9 @@ import org.junit.Test; import com.amazon.dlic.util.SettingsBasedSSLConfigurator; + import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; -import com.google.common.hash.Hashing; public class KeySetRetrieverTest { protected static MockIpdServer mockIdpServer; diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/MockIpdServer.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/MockIpdServer.java index b307d5f097..02f2e7a272 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/MockIpdServer.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/MockIpdServer.java @@ -15,8 +15,6 @@ package com.amazon.dlic.auth.http.jwt.keybyoidc; -import static com.amazon.dlic.auth.http.jwt.keybyoidc.CxfTestTools.toJson; - import java.io.Closeable; import java.io.FileInputStream; import java.io.IOException; @@ -58,6 +56,8 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; +import static com.amazon.dlic.auth.http.jwt.keybyoidc.CxfTestTools.toJson; + class MockIpdServer implements Closeable { final static String CTX_DISCOVER = "/discover"; final static String CTX_KEYS = "/api/oauth/keys"; diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySetTest.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySetTest.java index abf1cf6156..15c9c6d79d 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySetTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SelfRefreshingKeySetTest.java @@ -24,11 +24,6 @@ import org.junit.Assert; import org.junit.Test; -import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; -import com.amazon.dlic.auth.http.jwt.keybyoidc.BadCredentialsException; -import com.amazon.dlic.auth.http.jwt.keybyoidc.KeySetProvider; -import com.amazon.dlic.auth.http.jwt.keybyoidc.SelfRefreshingKeySet; - public class SelfRefreshingKeySetTest { @Test diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SingleKeyHTTPJwtKeyByOpenIdConnectAuthenticatorTest.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SingleKeyHTTPJwtKeyByOpenIdConnectAuthenticatorTest.java index 4b69d93c74..a85a4f701f 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SingleKeyHTTPJwtKeyByOpenIdConnectAuthenticatorTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/SingleKeyHTTPJwtKeyByOpenIdConnectAuthenticatorTest.java @@ -17,13 +17,13 @@ import java.util.HashMap; -import org.opensearch.common.settings.Settings; +import com.google.common.collect.ImmutableMap; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; -import com.google.common.collect.ImmutableMap; public class SingleKeyHTTPJwtKeyByOpenIdConnectAuthenticatorTest { diff --git a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/TestJwts.java b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/TestJwts.java index 1d8f804183..5aa2dde17b 100644 --- a/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/TestJwts.java +++ b/src/test/java/com/amazon/dlic/auth/http/jwt/keybyoidc/TestJwts.java @@ -17,6 +17,7 @@ import java.util.Set; +import com.google.common.collect.ImmutableSet; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; import org.apache.cxf.rs.security.jose.jws.JwsHeaders; import org.apache.cxf.rs.security.jose.jws.JwsSignatureProvider; @@ -27,8 +28,6 @@ import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.logging.log4j.util.Strings; -import com.google.common.collect.ImmutableSet; - class TestJwts { static final String ROLES_CLAIM = "roles"; static final Set TEST_ROLES = ImmutableSet.of("role1", "role2"); diff --git a/src/test/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticatorTest.java b/src/test/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticatorTest.java index e31121b358..38167ba481 100644 --- a/src/test/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticatorTest.java +++ b/src/test/java/com/amazon/dlic/auth/http/saml/HTTPSamlAuthenticatorTest.java @@ -34,9 +34,17 @@ import javax.net.ssl.KeyManagerFactory; -import org.opensearch.security.DefaultObjectMapper; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.common.collect.ImmutableMap; import org.apache.cxf.rs.security.jose.jws.JwsJwtCompactConsumer; import org.apache.cxf.rs.security.jose.jwt.JwtToken; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.opensaml.saml.saml2.core.NameIDType; + import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; @@ -48,19 +56,10 @@ import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestResponse; import org.opensearch.rest.RestStatus; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opensaml.saml.saml2.core.NameIDType; - +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; -import com.fasterxml.jackson.core.type.TypeReference; -import com.google.common.collect.ImmutableMap; import static com.amazon.dlic.auth.http.saml.HTTPSamlAuthenticator.IDP_METADATA_CONTENT; import static com.amazon.dlic.auth.http.saml.HTTPSamlAuthenticator.IDP_METADATA_URL; diff --git a/src/test/java/com/amazon/dlic/auth/http/saml/MockSamlIdpServer.java b/src/test/java/com/amazon/dlic/auth/http/saml/MockSamlIdpServer.java index b591a08ce3..fbd432baf9 100644 --- a/src/test/java/com/amazon/dlic/auth/http/saml/MockSamlIdpServer.java +++ b/src/test/java/com/amazon/dlic/auth/http/saml/MockSamlIdpServer.java @@ -67,6 +67,8 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import net.shibboleth.utilities.java.support.codec.Base64Support; +import net.shibboleth.utilities.java.support.component.ComponentInitializationException; import org.apache.http.Header; import org.apache.http.HttpConnectionFactory; import org.apache.http.HttpEntityEnclosingRequest; @@ -159,9 +161,6 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; -import net.shibboleth.utilities.java.support.codec.Base64Support; -import net.shibboleth.utilities.java.support.component.ComponentInitializationException; - class MockSamlIdpServer implements Closeable { final static String ENTITY_ID = "http://test.entity"; diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java index da835112f4..29612ad21a 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java @@ -15,16 +15,17 @@ package com.amazon.dlic.auth.ldap; -import org.opensearch.security.support.ConfigConstants; import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; + +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java index 71c6a188ec..105fd4abc4 100755 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.TreeSet; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -35,6 +33,9 @@ import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java index 2c57af013c..84ce9ef0dc 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java @@ -21,13 +21,14 @@ import java.net.URLDecoder; import java.nio.charset.StandardCharsets; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; import com.amazon.dlic.auth.ldap.util.ConfigConstants; + +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java index e4e482e115..b1c7f0dcdb 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.TreeSet; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -34,6 +32,9 @@ import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; + +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/com/amazon/dlic/auth/ldap/UtilsTest.java b/src/test/java/com/amazon/dlic/auth/ldap/UtilsTest.java index c44f147464..9ccb262f54 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/UtilsTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/UtilsTest.java @@ -21,8 +21,6 @@ import org.junit.Assert; import org.junit.Test; -import com.amazon.dlic.auth.ldap.util.Utils; - public class UtilsTest { diff --git a/src/test/java/com/amazon/dlic/auth/ldap/srv/LdapServer.java b/src/test/java/com/amazon/dlic/auth/ldap/srv/LdapServer.java index 83624cb778..034044af7f 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/srv/LdapServer.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/srv/LdapServer.java @@ -28,11 +28,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.network.SocketUtils; import com.google.common.io.CharStreams; import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; @@ -45,6 +40,12 @@ import com.unboundid.util.ssl.KeyStoreKeyManager; import com.unboundid.util.ssl.SSLUtil; import com.unboundid.util.ssl.TrustStoreTrustManager; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.network.SocketUtils; final class LdapServer { private final static Logger LOG = LogManager.getLogger(LdapServer.class); diff --git a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java index 827aeb4d87..3e8433b071 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java @@ -15,16 +15,17 @@ package com.amazon.dlic.auth.ldap2; -import org.opensearch.security.support.ConfigConstants; import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; + +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java index 7f22395952..45dd3e8fb4 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java @@ -21,13 +21,14 @@ import java.net.URLDecoder; import java.nio.charset.StandardCharsets; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import com.amazon.dlic.auth.ldap.LdapUser; import com.amazon.dlic.auth.ldap.util.ConfigConstants; + +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java index 0aadac3646..19a830fa26 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java @@ -21,8 +21,6 @@ import java.util.TreeSet; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -32,17 +30,18 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import org.ldaptive.Connection; -import org.ldaptive.LdapEntry; import org.ldaptive.LdapAttribute; - +import org.ldaptive.LdapEntry; import com.amazon.dlic.auth.ldap.LdapUser; +import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; +import com.amazon.dlic.auth.ldap.backend.LDAPAuthorizationBackend; import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; -import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; -import com.amazon.dlic.auth.ldap.backend.LDAPAuthorizationBackend; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java index f5273e871c..74ee21954c 100755 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java @@ -16,15 +16,12 @@ package com.amazon.dlic.auth.ldap2; import java.io.File; - import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.ArrayList; import java.util.TreeSet; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.common.settings.Settings; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -34,16 +31,18 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import org.ldaptive.Connection; -import org.ldaptive.LdapEntry; import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; import com.amazon.dlic.auth.ldap.LdapUser; +import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; +import com.amazon.dlic.auth.ldap.backend.LDAPAuthorizationBackend; import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; import com.amazon.dlic.auth.ldap.util.ConfigConstants; import com.amazon.dlic.auth.ldap.util.LdapHelper; -import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; -import com.amazon.dlic.auth.ldap.backend.LDAPAuthorizationBackend; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java index f17ce71b15..fde799b00b 100644 --- a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java +++ b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java @@ -15,20 +15,21 @@ package org.opensearch.security; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.SingleClusterTest; -import org.opensearch.security.test.helper.cluster.ClusterConfiguration; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.io.File; +import java.util.Arrays; + import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.util.Arrays; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.SingleClusterTest; +import org.opensearch.security.test.helper.cluster.ClusterConfiguration; +import org.opensearch.security.test.helper.rest.RestHelper; public class AdvancedSecurityMigrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/AggregationTests.java b/src/test/java/org/opensearch/security/AggregationTests.java index 4416b3f2d4..f24d11598c 100644 --- a/src/test/java/org/opensearch/security/AggregationTests.java +++ b/src/test/java/org/opensearch/security/AggregationTests.java @@ -31,6 +31,9 @@ package org.opensearch.security; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -39,9 +42,6 @@ import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/ConfigTests.java b/src/test/java/org/opensearch/security/ConfigTests.java index 46a36454b5..cd7c21b892 100644 --- a/src/test/java/org/opensearch/security/ConfigTests.java +++ b/src/test/java/org/opensearch/security/ConfigTests.java @@ -19,15 +19,15 @@ import java.io.File; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.apache.commons.io.FileUtils; -import org.opensearch.common.Strings; -import org.opensearch.common.collect.Tuple; import org.junit.Assert; import org.junit.Test; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import org.opensearch.common.Strings; +import org.opensearch.common.collect.Tuple; import org.opensearch.security.securityconf.Migration; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; diff --git a/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java b/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java index 3d314c685e..b6077f7fec 100644 --- a/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java +++ b/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java @@ -18,6 +18,7 @@ import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; + import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java b/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java index 93cc00463b..e60a05a142 100644 --- a/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java +++ b/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java @@ -14,15 +14,16 @@ */ package org.opensearch.security; +import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + +import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.SecuritySettings; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.junit.Assert; -import org.junit.Test; public class EncryptionInTransitMigrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/HealthTests.java b/src/test/java/org/opensearch/security/HealthTests.java index 624e17f0a6..00efcc5de6 100644 --- a/src/test/java/org/opensearch/security/HealthTests.java +++ b/src/test/java/org/opensearch/security/HealthTests.java @@ -31,14 +31,14 @@ package org.opensearch.security; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class HealthTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/HttpIntegrationTests.java b/src/test/java/org/opensearch/security/HttpIntegrationTests.java index c45000f504..c8c4a09d19 100644 --- a/src/test/java/org/opensearch/security/HttpIntegrationTests.java +++ b/src/test/java/org/opensearch/security/HttpIntegrationTests.java @@ -38,7 +38,10 @@ import org.apache.http.HttpStatus; import org.apache.http.NoHttpResponseException; import org.apache.http.message.BasicHeader; -import org.checkerframework.checker.units.qual.C; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -47,11 +50,6 @@ import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; import org.opensearch.security.action.configupdate.ConfigUpdateResponse; @@ -61,7 +59,7 @@ import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; - +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.opensearch.security.DefaultObjectMapper.readTree; diff --git a/src/test/java/org/opensearch/security/IndexIntegrationTests.java b/src/test/java/org/opensearch/security/IndexIntegrationTests.java index 9044c71027..ece867b602 100644 --- a/src/test/java/org/opensearch/security/IndexIntegrationTests.java +++ b/src/test/java/org/opensearch/security/IndexIntegrationTests.java @@ -35,30 +35,29 @@ import java.util.Date; import java.util.TimeZone; -import org.opensearch.client.Client; -import org.opensearch.security.support.SecurityUtils; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.delete.DeleteIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.QueryBuilders; import org.opensearch.indices.InvalidIndexNameException; -import org.opensearch.indices.InvalidTypeNameException; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.SecurityUtils; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class IndexIntegrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/InitializationIntegrationTests.java b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java index 7f426c2a0b..08848cbb05 100644 --- a/src/test/java/org/opensearch/security/InitializationIntegrationTests.java +++ b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java @@ -37,6 +37,9 @@ import org.apache.http.Header; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.action.index.IndexRequest; @@ -48,10 +51,6 @@ import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; -import org.junit.Assert; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; import org.opensearch.security.action.configupdate.ConfigUpdateResponse; @@ -61,6 +60,7 @@ import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class InitializationIntegrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/IntegrationTests.java b/src/test/java/org/opensearch/security/IntegrationTests.java index 8d2013e7c5..055b9491a4 100644 --- a/src/test/java/org/opensearch/security/IntegrationTests.java +++ b/src/test/java/org/opensearch/security/IntegrationTests.java @@ -30,29 +30,26 @@ package org.opensearch.security; -import com.fasterxml.jackson.databind.JsonNode; -import io.netty.handler.ssl.OpenSsl; - import java.lang.Thread.UncaughtExceptionHandler; import java.util.TreeSet; +import com.fasterxml.jackson.databind.JsonNode; +import io.netty.handler.ssl.OpenSsl; import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; - import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; import org.opensearch.security.action.configupdate.ConfigUpdateResponse; @@ -63,6 +60,7 @@ import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.opensearch.security.DefaultObjectMapper.readTree; diff --git a/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java b/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java index 6bc3e67847..9ddff6414c 100644 --- a/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java +++ b/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java @@ -1,7 +1,9 @@ package org.opensearch.security; +import com.google.common.collect.ImmutableMap; import org.junit.Assert; import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; @@ -10,8 +12,6 @@ import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; -import com.google.common.collect.ImmutableMap; - public class PrivilegesEvaluationTest extends SingleClusterTest { @Test public void resolveTestHidden() throws Exception { diff --git a/src/test/java/org/opensearch/security/ResolveAPITests.java b/src/test/java/org/opensearch/security/ResolveAPITests.java index 743a5e22a7..4915cec4d7 100644 --- a/src/test/java/org/opensearch/security/ResolveAPITests.java +++ b/src/test/java/org/opensearch/security/ResolveAPITests.java @@ -16,15 +16,16 @@ package org.opensearch.security; import org.apache.http.HttpStatus; -import org.opensearch.client.Client; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.test.DynamicSecurityConfig; diff --git a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java index 586d38c7bc..aac9a93b98 100644 --- a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java @@ -15,9 +15,14 @@ package org.opensearch.security; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.SingleClusterTest; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Supplier; + +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -39,16 +44,12 @@ import org.opensearch.plugins.Plugin; import org.opensearch.repositories.RepositoriesService; import org.opensearch.script.ScriptService; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.SingleClusterTest; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.Netty4Plugin; import org.opensearch.watcher.ResourceWatcherService; -import org.junit.Assert; -import org.junit.Test; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.function.Supplier; public class RolesInjectorIntegTest extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/RolesValidationIntegTest.java b/src/test/java/org/opensearch/security/RolesValidationIntegTest.java index 6fa39cf25e..ba36653fe8 100644 --- a/src/test/java/org/opensearch/security/RolesValidationIntegTest.java +++ b/src/test/java/org/opensearch/security/RolesValidationIntegTest.java @@ -1,7 +1,13 @@ package org.opensearch.security; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Supplier; + import org.junit.Assert; import org.junit.Test; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -29,11 +35,6 @@ import org.opensearch.transport.Netty4Plugin; import org.opensearch.watcher.ResourceWatcherService; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.function.Supplier; - public class RolesValidationIntegTest extends SingleClusterTest { public static class RolesValidationPlugin extends Plugin implements ActionPlugin { diff --git a/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java b/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java index 1230b2b669..3251189b8b 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java @@ -8,6 +8,7 @@ import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; + import org.opensearch.common.settings.Settings; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java b/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java index e0cfec3eac..277195cc20 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java @@ -34,15 +34,15 @@ import java.util.ArrayList; import java.util.List; -import org.opensearch.common.settings.Settings; -import org.opensearch.security.tools.SecurityAdmin; import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.tools.SecurityAdmin; public class SecurityAdminInvalidConfigsTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/SecurityAdminTests.java b/src/test/java/org/opensearch/security/SecurityAdminTests.java index bc84e39220..18e6397ad7 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminTests.java @@ -21,18 +21,18 @@ import java.util.ArrayList; import java.util.List; -import org.opensearch.security.tools.SecurityAdmin; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.security.tools.SecurityAdmin; public class SecurityAdminTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/SecurityRolesTests.java b/src/test/java/org/opensearch/security/SecurityRolesTests.java index eb09d75ffa..28b48de97c 100644 --- a/src/test/java/org/opensearch/security/SecurityRolesTests.java +++ b/src/test/java/org/opensearch/security/SecurityRolesTests.java @@ -32,15 +32,15 @@ import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class SecurityRolesTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/SlowIntegrationTests.java b/src/test/java/org/opensearch/security/SlowIntegrationTests.java index df5c6325c1..0faf1104a9 100644 --- a/src/test/java/org/opensearch/security/SlowIntegrationTests.java +++ b/src/test/java/org/opensearch/security/SlowIntegrationTests.java @@ -30,7 +30,12 @@ package org.opensearch.security; +import java.io.IOException; + import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; @@ -41,14 +46,11 @@ import org.opensearch.node.PluginAwareNode; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.transport.Netty4Plugin; -import org.junit.Assert; -import org.junit.Test; -import java.io.IOException; public class SlowIntegrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java index 69f94bafc6..9f93f92739 100644 --- a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java +++ b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java @@ -34,13 +34,6 @@ import java.util.Collection; import org.apache.http.HttpStatus; -import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; -import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; -import org.opensearch.action.index.IndexRequest; -import org.opensearch.action.support.WriteRequest.RefreshPolicy; -import org.opensearch.client.Client; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,6 +41,13 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; +import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; +import org.opensearch.action.index.IndexRequest; +import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; import org.opensearch.security.action.configupdate.ConfigUpdateResponse; diff --git a/src/test/java/org/opensearch/security/SystemIntegratorsTests.java b/src/test/java/org/opensearch/security/SystemIntegratorsTests.java index c7f068f3b1..764be992ba 100644 --- a/src/test/java/org/opensearch/security/SystemIntegratorsTests.java +++ b/src/test/java/org/opensearch/security/SystemIntegratorsTests.java @@ -30,18 +30,18 @@ package org.opensearch.security; +import com.google.common.collect.Lists; import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.rest.RestHelper; -import com.google.common.collect.Lists; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class SystemIntegratorsTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/TaskTests.java b/src/test/java/org/opensearch/security/TaskTests.java index 7c77417477..d3ad0cd03a 100644 --- a/src/test/java/org/opensearch/security/TaskTests.java +++ b/src/test/java/org/opensearch/security/TaskTests.java @@ -19,14 +19,15 @@ import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.common.settings.Settings; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; -import org.opensearch.tasks.Task; -import org.junit.Assert; -import org.junit.Test; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.tasks.Task; public class TaskTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/TracingTests.java b/src/test/java/org/opensearch/security/TracingTests.java index 32cdb0bbf4..437eb49fe1 100644 --- a/src/test/java/org/opensearch/security/TracingTests.java +++ b/src/test/java/org/opensearch/security/TracingTests.java @@ -33,6 +33,10 @@ import java.lang.Thread.UncaughtExceptionHandler; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -42,10 +46,6 @@ import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; diff --git a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java index 1c37093573..6a96c02926 100644 --- a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java @@ -1,8 +1,13 @@ package org.opensearch.security; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.SingleClusterTest; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Supplier; + +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -21,16 +26,12 @@ import org.opensearch.plugins.Plugin; import org.opensearch.repositories.RepositoriesService; import org.opensearch.script.ScriptService; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.SingleClusterTest; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.Netty4Plugin; import org.opensearch.watcher.ResourceWatcherService; -import org.junit.Assert; -import org.junit.Test; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.function.Supplier; public class TransportUserInjectorIntegTest extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/UtilTests.java b/src/test/java/org/opensearch/security/UtilTests.java index a28ca7edf6..5bec946d2d 100644 --- a/src/test/java/org/opensearch/security/UtilTests.java +++ b/src/test/java/org/opensearch/security/UtilTests.java @@ -30,21 +30,21 @@ package org.opensearch.security; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - import java.util.Map; -import org.opensearch.security.support.SecurityUtils; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; -import org.opensearch.common.settings.Settings; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.SecurityUtils; import org.opensearch.security.support.WildcardMatcher; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class UtilTests { static private WildcardMatcher wc(String pattern) { diff --git a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java index 0d1490997b..db0f4d242c 100644 --- a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java +++ b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java @@ -17,18 +17,18 @@ import java.util.Collection; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.config.AuditConfig; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.http.Header; -import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.routing.AuditMessageRouter; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; -import com.fasterxml.jackson.databind.JsonNode; public abstract class AbstractAuditlogiUnitTest extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java b/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java index be2fc3a973..63256cfbe1 100644 --- a/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java +++ b/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java @@ -15,21 +15,22 @@ package org.opensearch.security.auditlog; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.auditlog.impl.AbstractAuditLog; -import org.opensearch.security.auditlog.impl.AuditLogImpl; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.nio.file.Path; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; + import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; +import org.opensearch.security.auditlog.config.AuditConfig; +import org.opensearch.security.auditlog.impl.AbstractAuditLog; +import org.opensearch.security.auditlog.impl.AuditLogImpl; +import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.threadpool.ThreadPool; -import java.nio.file.Path; - import static org.junit.Assert.assertEquals; public class AuditTestUtils { diff --git a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java index 16345951c4..c85a78e6bb 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java @@ -15,31 +15,30 @@ package org.opensearch.security.auditlog.compliance; -import org.opensearch.action.get.GetRequest; -import org.opensearch.action.get.GetResponse; -import org.opensearch.client.Client; -import org.opensearch.client.RequestOptions; -import org.opensearch.client.RestHighLevelClient; -import org.opensearch.security.auditlog.AuditTestUtils; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.compliance.ComplianceConfig; +import java.util.Collections; + import com.google.common.collect.ImmutableMap; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.action.index.IndexRequest; -import org.opensearch.action.support.WriteRequest.RefreshPolicy; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.action.get.GetRequest; +import org.opensearch.action.get.GetResponse; +import org.opensearch.action.index.IndexRequest; +import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; +import org.opensearch.client.RequestOptions; +import org.opensearch.client.RestHighLevelClient; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; +import org.opensearch.security.auditlog.AuditTestUtils; +import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.auditlog.integration.TestAuditlogImpl; +import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.helper.rest.RestHelper; - -import java.util.Collections; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java index f0ae922ce4..34e2c39689 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java @@ -15,20 +15,20 @@ package org.opensearch.security.auditlog.compliance; -import org.opensearch.security.compliance.ComplianceConfig; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.WildcardMatcher; +import java.util.Collections; import com.google.common.collect.ImmutableSet; -import org.opensearch.common.settings.Settings; import org.junit.Test; -import java.util.Collections; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.compliance.ComplianceConfig; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.WildcardMatcher; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; public class ComplianceConfigTest { diff --git a/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java index c7ce95e023..4339b5bec3 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java @@ -15,14 +15,14 @@ package org.opensearch.security.auditlog.compliance; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.integration.TestAuditlogImpl; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java index 740f59c8b4..aa8518bded 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java @@ -15,26 +15,26 @@ package org.opensearch.security.auditlog.config; +import java.util.Collections; +import java.util.EnumSet; + +import org.junit.Test; + +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; -import org.opensearch.common.settings.Settings; -import org.junit.Test; - -import java.util.Collections; -import java.util.EnumSet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import static org.opensearch.security.auditlog.impl.AuditCategory.AUTHENTICATED; -import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; import static org.opensearch.security.auditlog.impl.AuditCategory.BAD_HEADERS; -import static org.opensearch.security.auditlog.impl.AuditCategory.SSL_EXCEPTION; import static org.opensearch.security.auditlog.impl.AuditCategory.FAILED_LOGIN; +import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; import static org.opensearch.security.auditlog.impl.AuditCategory.MISSING_PRIVILEGES; - -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; +import static org.opensearch.security.auditlog.impl.AuditCategory.SSL_EXCEPTION; public class AuditConfigFilterTest { diff --git a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java index dbb50cb42d..ae41701429 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java @@ -15,34 +15,34 @@ package org.opensearch.security.auditlog.config; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.compliance.ComplianceConfig; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.WildcardMatcher; +import java.io.IOException; +import java.util.Collections; +import java.util.EnumSet; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.junit.Before; +import org.junit.Test; + import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.Collections; -import java.util.EnumSet; - -import static org.opensearch.security.auditlog.impl.AuditCategory.AUTHENTICATED; -import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.compliance.ComplianceConfig; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.WildcardMatcher; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; +import static org.opensearch.security.auditlog.impl.AuditCategory.AUTHENTICATED; +import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; public class AuditConfigSerializeTest { diff --git a/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java b/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java index 7aed35e156..cb0c9af8e9 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java @@ -15,11 +15,12 @@ package org.opensearch.security.auditlog.config; -import org.opensearch.common.settings.Settings; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.opensearch.common.settings.Settings; + import static org.junit.Assert.assertEquals; public class ThreadPoolConfigTest { diff --git a/src/test/java/org/opensearch/security/auditlog/helper/FailingSink.java b/src/test/java/org/opensearch/security/auditlog/helper/FailingSink.java index c785b427a8..bf8defa922 100644 --- a/src/test/java/org/opensearch/security/auditlog/helper/FailingSink.java +++ b/src/test/java/org/opensearch/security/auditlog/helper/FailingSink.java @@ -16,7 +16,6 @@ package org.opensearch.security.auditlog.helper; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/helper/LoggingSink.java b/src/test/java/org/opensearch/security/auditlog/helper/LoggingSink.java index 3cd8c8e5d0..7210ef2591 100644 --- a/src/test/java/org/opensearch/security/auditlog/helper/LoggingSink.java +++ b/src/test/java/org/opensearch/security/auditlog/helper/LoggingSink.java @@ -19,7 +19,6 @@ import java.util.List; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/helper/MockAuditMessageFactory.java b/src/test/java/org/opensearch/security/auditlog/helper/MockAuditMessageFactory.java index a816ad25ea..0b43708059 100644 --- a/src/test/java/org/opensearch/security/auditlog/helper/MockAuditMessageFactory.java +++ b/src/test/java/org/opensearch/security/auditlog/helper/MockAuditMessageFactory.java @@ -15,19 +15,18 @@ package org.opensearch.security.auditlog.helper; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.net.InetSocketAddress; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.transport.TransportAddress; - -import org.opensearch.security.auditlog.impl.AuditMessage; -import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.security.auditlog.AuditLog.Origin; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class MockAuditMessageFactory { diff --git a/src/test/java/org/opensearch/security/auditlog/helper/RetrySink.java b/src/test/java/org/opensearch/security/auditlog/helper/RetrySink.java index e011f6dff7..e57430ba39 100644 --- a/src/test/java/org/opensearch/security/auditlog/helper/RetrySink.java +++ b/src/test/java/org/opensearch/security/auditlog/helper/RetrySink.java @@ -16,7 +16,6 @@ package org.opensearch.security.auditlog.helper; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/helper/SlowSink.java b/src/test/java/org/opensearch/security/auditlog/helper/SlowSink.java index a4029b70e8..f08072fac6 100644 --- a/src/test/java/org/opensearch/security/auditlog/helper/SlowSink.java +++ b/src/test/java/org/opensearch/security/auditlog/helper/SlowSink.java @@ -16,7 +16,6 @@ package org.opensearch.security.auditlog.helper; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/impl/AuditCategoryTest.java b/src/test/java/org/opensearch/security/auditlog/impl/AuditCategoryTest.java index 83c6060e5c..1aa308d51b 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditCategoryTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditCategoryTest.java @@ -15,18 +15,18 @@ package org.opensearch.security.auditlog.impl; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; import java.util.List; import java.util.Set; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + import static org.opensearch.security.auditlog.impl.AuditCategory.AUTHENTICATED; import static org.opensearch.security.auditlog.impl.AuditCategory.BAD_HEADERS; diff --git a/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java b/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java index 61497328f6..03e119c223 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java @@ -15,23 +15,24 @@ package org.opensearch.security.auditlog.impl; -import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.securityconf.impl.CType; +import java.nio.ByteBuffer; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.junit.Before; +import org.junit.Test; + import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.xcontent.XContentType; -import org.junit.Before; -import org.junit.Test; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.securityconf.impl.CType; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; diff --git a/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java index e8db4c5cb7..0df3bd287a 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java @@ -15,10 +15,10 @@ package org.opensearch.security.auditlog.impl; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.ClusterName; @@ -26,15 +26,15 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.rest.RestRequest; +import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.security.auditlog.helper.RetrySink; import org.opensearch.security.auditlog.integration.TestAuditlogImpl; import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.AbstractSecurityUnitTest; import org.opensearch.transport.TransportRequest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opensearch.security.test.AbstractSecurityUnitTest; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class AuditlogTest { diff --git a/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java b/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java index 8d6e0a709a..29555504b7 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java @@ -15,10 +15,10 @@ package org.opensearch.security.auditlog.impl; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.settings.Settings.Builder; import org.junit.Test; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.Settings.Builder; import org.opensearch.security.auditlog.helper.MyOwnAuditLog; import org.opensearch.security.auditlog.sink.AuditLogSink; import org.opensearch.security.auditlog.sink.DebugSink; diff --git a/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java b/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java index 07f75501fb..b7f45988e6 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java @@ -15,35 +15,34 @@ package org.opensearch.security.auditlog.impl; -import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import org.opensearch.security.auditlog.AuditTestUtils; -import org.opensearch.security.test.AbstractSecurityUnitTest; +import com.google.common.base.Joiner; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.Settings.Builder; import org.opensearch.security.auditlog.AuditLog; +import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.security.auditlog.helper.MockRestRequest; import org.opensearch.security.auditlog.integration.TestAuditlogImpl; import org.opensearch.security.support.ConfigConstants; -import org.opensearch.tasks.Task; +import org.opensearch.security.test.AbstractSecurityUnitTest; import org.opensearch.transport.TransportRequest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import com.google.common.base.Joiner; -import org.junit.rules.ExpectedException; +import static org.hamcrest.CoreMatchers.containsString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class DisabledCategoriesTest { diff --git a/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java b/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java index 44c92e84d8..8a703c8a4b 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java @@ -15,26 +15,27 @@ package org.opensearch.security.auditlog.impl; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.net.InetSocketAddress; -import org.opensearch.security.auditlog.AuditTestUtils; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; +import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.security.auditlog.integration.TestAuditlogImpl; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Created by martin.stange on 19.04.2017. diff --git a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java index 60f0cde15e..2625855890 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java @@ -17,29 +17,27 @@ import java.lang.Thread.UncaughtExceptionHandler; -import org.opensearch.client.Client; -import org.opensearch.security.auditlog.AuditTestUtils; - import net.jcip.annotations.NotThreadSafe; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; - -import org.junit.Assert; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; @NotThreadSafe public class TracingTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java index 3317fada98..ee58334395 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java @@ -15,45 +15,36 @@ package org.opensearch.security.auditlog.integration; -import org.opensearch.client.Client; -import org.opensearch.client.RequestOptions; -import org.opensearch.client.RestHighLevelClient; -import org.opensearch.security.auditlog.AuditTestUtils; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.compliance.ComplianceConfig; +import java.util.Collections; +import java.util.List; + import com.google.common.collect.ImmutableMap; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.apache.http.NoHttpResponseException; import org.apache.http.message.BasicHeader; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; -import org.opensearch.action.search.SearchRequest; -import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; +import org.opensearch.security.auditlog.AuditTestUtils; +import org.opensearch.security.auditlog.config.AuditConfig; +import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.security.auditlog.impl.AuditMessage; +import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static org.opensearch.rest.RestRequest.Method.GET; import static org.opensearch.rest.RestRequest.Method.DELETE; +import static org.opensearch.rest.RestRequest.Method.GET; import static org.opensearch.rest.RestRequest.Method.PATCH; import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.rest.RestRequest.Method.PUT; diff --git a/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java index e79bbe0311..4397c07987 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java @@ -16,12 +16,11 @@ package org.opensearch.security.auditlog.integration; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.After; import org.junit.Assert; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; @@ -30,6 +29,7 @@ import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class SSLAuditlogTest extends AbstractAuditlogiUnitTest { diff --git a/src/test/java/org/opensearch/security/auditlog/integration/TestAuditlogImpl.java b/src/test/java/org/opensearch/security/auditlog/integration/TestAuditlogImpl.java index a160a2504d..aaeffe26a2 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/TestAuditlogImpl.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/TestAuditlogImpl.java @@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java b/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java index 5409ebbf60..2c4d134e80 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java @@ -20,16 +20,16 @@ import java.util.List; import java.util.stream.Collectors; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; import org.opensearch.security.auditlog.helper.FailingSink; import org.opensearch.security.auditlog.helper.LoggingSink; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java b/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java index 74870b4f8c..c0fb96b5ff 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java @@ -15,16 +15,16 @@ package org.opensearch.security.auditlog.routing; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; import org.opensearch.security.auditlog.helper.LoggingSink; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java b/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java index dd542c1772..ae8a779d7b 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java @@ -19,15 +19,15 @@ import java.util.List; import java.util.Map; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; import org.opensearch.security.auditlog.helper.LoggingSink; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; import org.opensearch.security.auditlog.sink.DebugSink; import org.opensearch.security.auditlog.sink.ExternalOpenSearchSink; diff --git a/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java b/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java index 95e3894941..a83bb3173c 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java @@ -18,12 +18,12 @@ import java.util.List; import java.util.Objects; -import org.opensearch.security.auditlog.config.ThreadPoolConfig; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; +import org.opensearch.security.auditlog.config.ThreadPoolConfig; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java b/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java index 8cfaa8fcfb..71fc57585c 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java @@ -21,19 +21,18 @@ import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.yaml.YamlXContent; import org.junit.Assert; import org.junit.ClassRule; import org.junit.Test; -import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.test.helper.file.FileHelper; import org.springframework.kafka.test.rule.EmbeddedKafkaRule; - import scala.util.Random; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.yaml.YamlXContent; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; +import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.test.helper.file.FileHelper; public class KafkaSinkTest extends AbstractAuditlogiUnitTest { diff --git a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java index 65ef61f35d..c7c8c3b5a7 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java @@ -27,17 +27,17 @@ import org.apache.http.impl.bootstrap.HttpServer; import org.apache.http.impl.bootstrap.ServerBootstrap; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.settings.Settings.Builder; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.Settings.Builder; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; import org.opensearch.security.auditlog.helper.TestHttpHandler; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.test.helper.file.FileHelper; public class SinkProviderTLSTest { diff --git a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java index 24af7636da..d4b3b63117 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java @@ -16,10 +16,10 @@ package org.opensearch.security.auditlog.sink; import org.apache.logging.log4j.Level; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.test.helper.file.FileHelper; public class SinkProviderTest { diff --git a/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java b/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java index 2efe9ad40c..8e40f805b3 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java @@ -31,18 +31,18 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.bootstrap.HttpServer; import org.apache.http.impl.bootstrap.ServerBootstrap; -import org.opensearch.common.settings.Settings; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opensearch.security.auditlog.sink.WebhookSink.WebhookFormat; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.helper.LoggingSink; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; import org.opensearch.security.auditlog.helper.TestHttpHandler; -import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; +import org.opensearch.security.auditlog.sink.WebhookSink.WebhookFormat; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java b/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java index 626b5224ba..0656f9ccd1 100644 --- a/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java +++ b/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java @@ -15,23 +15,24 @@ package org.opensearch.security.auth; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + import org.junit.Before; +import org.junit.Test; + +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.concurrent.ThreadContext; -import org.junit.Test; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.opensearch.security.support.ConfigConstants.OPENDISTRO_SECURITY_INJECTED_ROLES; -import static org.junit.Assert.assertEquals; public class RolesInjectorTest { diff --git a/src/test/java/org/opensearch/security/auth/UserInjectorTest.java b/src/test/java/org/opensearch/security/auth/UserInjectorTest.java index 26a3b41ec5..cfde2c89de 100644 --- a/src/test/java/org/opensearch/security/auth/UserInjectorTest.java +++ b/src/test/java/org/opensearch/security/auth/UserInjectorTest.java @@ -1,20 +1,21 @@ package org.opensearch.security.auth; +import java.util.Arrays; +import java.util.HashSet; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.http.XFFResolver; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.HashSet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; diff --git a/src/test/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistryTest.java b/src/test/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistryTest.java index e73478ffdd..391b48ed70 100644 --- a/src/test/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistryTest.java +++ b/src/test/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistryTest.java @@ -17,11 +17,11 @@ package org.opensearch.security.auth.blocking; +import org.junit.Test; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Test; - public class HeapBasedClientBlockRegistryTest { @Test diff --git a/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java b/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java index 6eda313c32..bd0cadfa6c 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java @@ -17,14 +17,14 @@ package org.opensearch.security.auth.limiting; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.opensearch.common.settings.Settings; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class AddressBasedRateLimiterTest { private final static byte[] PASSWORD = new byte[] { '1', '2', '3' }; diff --git a/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java b/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java index 3637211eec..c605fe57b9 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java @@ -17,13 +17,13 @@ package org.opensearch.security.auth.limiting; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.junit.Test; import org.opensearch.security.util.ratetracking.HeapBasedRateTracker; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class HeapBasedRateTrackerTest { @Test diff --git a/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java b/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java index 4b86617b3d..9e7d95fd00 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java @@ -17,14 +17,15 @@ package org.opensearch.security.auth.limiting; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.net.InetAddress; -import org.opensearch.common.settings.Settings; import org.junit.Test; +import org.opensearch.common.settings.Settings; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class UserNameBasedRateLimiterTest { @Test diff --git a/src/test/java/org/opensearch/security/cache/CachingTest.java b/src/test/java/org/opensearch/security/cache/CachingTest.java index 3627de1657..d9c6a22fd4 100644 --- a/src/test/java/org/opensearch/security/cache/CachingTest.java +++ b/src/test/java/org/opensearch/security/cache/CachingTest.java @@ -17,15 +17,15 @@ import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.common.settings.Settings; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class CachingTest extends SingleClusterTest{ diff --git a/src/test/java/org/opensearch/security/cache/DummyAuthenticationBackend.java b/src/test/java/org/opensearch/security/cache/DummyAuthenticationBackend.java index 063eb6a90c..f45dc62e10 100644 --- a/src/test/java/org/opensearch/security/cache/DummyAuthenticationBackend.java +++ b/src/test/java/org/opensearch/security/cache/DummyAuthenticationBackend.java @@ -19,7 +19,6 @@ import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthenticationBackend; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/test/java/org/opensearch/security/cache/DummyAuthorizer.java b/src/test/java/org/opensearch/security/cache/DummyAuthorizer.java index b59a8e37b7..ed6a383213 100644 --- a/src/test/java/org/opensearch/security/cache/DummyAuthorizer.java +++ b/src/test/java/org/opensearch/security/cache/DummyAuthorizer.java @@ -19,7 +19,6 @@ import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; - import org.opensearch.security.auth.AuthorizationBackend; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; diff --git a/src/test/java/org/opensearch/security/cache/DummyHTTPAuthenticator.java b/src/test/java/org/opensearch/security/cache/DummyHTTPAuthenticator.java index f6b79428c8..bedfb67f39 100644 --- a/src/test/java/org/opensearch/security/cache/DummyHTTPAuthenticator.java +++ b/src/test/java/org/opensearch/security/cache/DummyHTTPAuthenticator.java @@ -22,7 +22,6 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; - import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java index a665f79923..020d1c56fc 100644 --- a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java +++ b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java @@ -30,43 +30,43 @@ package org.opensearch.security.ccstest; +import org.apache.http.HttpStatus; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; +import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; +import org.opensearch.action.index.IndexRequest; +import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.cluster.health.ClusterHealthStatus; +import org.opensearch.common.collect.Tuple; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.node.Node; import org.opensearch.node.PluginAwareNode; import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.RolesInjectorIntegTest; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.NodeSettingsSupplier; -import org.opensearch.security.test.helper.file.FileHelper; -import org.apache.http.HttpStatus; -import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; -import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; -import org.opensearch.action.index.IndexRequest; -import org.opensearch.action.support.WriteRequest.RefreshPolicy; -import org.opensearch.common.collect.Tuple; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.test.AbstractSecurityUnitTest; import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.NodeSettingsSupplier; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.cluster.ClusterHelper; import org.opensearch.security.test.helper.cluster.ClusterInfo; +import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.transport.Netty4Plugin; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java index 48401ae60c..46f998ab6f 100644 --- a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java +++ b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java @@ -30,23 +30,23 @@ package org.opensearch.security.ccstest; -import org.opensearch.client.Client; -import org.opensearch.security.test.AbstractSecurityUnitTest; import org.apache.http.HttpStatus; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import org.opensearch.security.test.AbstractSecurityUnitTest; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.cluster.ClusterHelper; import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.rest.RestHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class RemoteReindexTests extends AbstractSecurityUnitTest { diff --git a/src/test/java/org/opensearch/security/configuration/SaltTest.java b/src/test/java/org/opensearch/security/configuration/SaltTest.java index b23b41f343..6ee585e4b0 100644 --- a/src/test/java/org/opensearch/security/configuration/SaltTest.java +++ b/src/test/java/org/opensearch/security/configuration/SaltTest.java @@ -15,18 +15,19 @@ package org.opensearch.security.configuration; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.OpenSearchException; -import org.opensearch.common.settings.Settings; +import java.nio.charset.StandardCharsets; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.nio.charset.StandardCharsets; +import org.opensearch.OpenSearchException; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; -import static org.opensearch.security.configuration.Salt.SALT_SIZE; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.opensearch.security.configuration.Salt.SALT_SIZE; public class SaltTest { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java index 2ea9bf4462..b0b9a73bf2 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java @@ -15,16 +15,17 @@ package org.opensearch.security.dlic.dlsfls; -import org.opensearch.client.Client; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.junit.Assert; + import org.opensearch.action.get.GetResponse; import org.opensearch.action.get.MultiGetResponse; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.SearchResponse; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java index 3837eb50bb..6c7b5e1b06 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java @@ -22,13 +22,10 @@ import java.util.List; import java.util.function.Supplier; -import org.checkerframework.checker.units.qual.C; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.cluster.health.ClusterHealthStatus; -import org.opensearch.common.io.stream.StreamInput; -import org.opensearch.common.io.stream.StreamOutput; import org.junit.Assert; import org.junit.Test; + +import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; @@ -45,10 +42,13 @@ import org.opensearch.action.support.master.AcknowledgedRequest; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.Client; +import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.io.stream.NamedWriteableRegistry; +import org.opensearch.common.io.stream.StreamInput; +import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentType; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java index 0cb392c66e..2e5c888a06 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java @@ -18,14 +18,14 @@ import java.nio.charset.StandardCharsets; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java index 7d10807c01..037826543e 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class CustomFieldMaskedTest extends AbstractDlsFlsTest { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java index 049f32cf76..43d2abffef 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java @@ -20,13 +20,13 @@ import java.util.TimeZone; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.support.SecurityUtils; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java index 18e2f68695..6c420c03c8 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java @@ -17,6 +17,7 @@ import org.junit.Assert; import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java index 4280fc80e1..7f50d6bf93 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java @@ -20,14 +20,14 @@ import java.time.format.DateTimeFormatter; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java index c0133c2463..6527e091e1 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java @@ -16,11 +16,6 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; -import org.opensearch.action.index.IndexRequest; -import org.opensearch.action.support.WriteRequest.RefreshPolicy; -import org.opensearch.client.Client; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -29,6 +24,11 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.opensearch.action.index.IndexRequest; +import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.test.AbstractSecurityUnitTest; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java index 0dbceab386..c80b64b3bd 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java @@ -16,15 +16,15 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class DlsNestedTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java index b1158546c5..f6616c536b 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class DlsPropsReplaceTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java index fe759f6f37..b621470ba6 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class DlsScrollTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java index ce75ebcfce..2b607c95f6 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java @@ -15,8 +15,6 @@ package org.opensearch.security.dlic.dlsfls; -import static org.opensearch.security.dlic.dlsfls.DlsTermsLookupAsserts.assertAccessCodesMatch; - import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -26,6 +24,7 @@ import org.junit.Assert; import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.get.GetResponse; @@ -55,6 +54,8 @@ import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import static org.opensearch.security.dlic.dlsfls.DlsTermsLookupAsserts.assertAccessCodesMatch; + public class DlsTermLookupQueryTest extends AbstractDlsFlsTest { protected void populateData(Client client) { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java index c429f18471..03a506482d 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java @@ -15,15 +15,16 @@ package org.opensearch.security.dlic.dlsfls; -import static org.junit.Assert.assertTrue; - import java.util.Arrays; import java.util.Collection; import java.util.Map; import org.junit.Assert; + import org.opensearch.search.SearchHit; +import static org.junit.Assert.assertTrue; + /* * Copyright OpenSearch Contributors * diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java index 7c704c2bda..8726d04e53 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java @@ -15,8 +15,10 @@ package org.opensearch.security.dlic.dlsfls; -import com.google.common.collect.ImmutableMap; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; @@ -24,9 +26,6 @@ import org.opensearch.client.Client; import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class DlsTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java index 55a1e9e28a..199cd230bf 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FieldMaskedTest extends AbstractDlsFlsTest { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java b/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java index 222f0ac402..80adb56fbd 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java index 9d609d4137..75915308d3 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java @@ -16,15 +16,15 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FlsDlsTestAB extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java index b7446e7f5a..f337b13330 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FlsDlsTestForbiddenField extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java index 2556559090..770ec44268 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FlsDlsTestMulti extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java index 80d17d3ee0..90181ff3f3 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java @@ -16,14 +16,14 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FlsExistsFieldsTest extends AbstractDlsFlsTest { diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java index 91e0544cb4..ecf6c4b50d 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java @@ -18,14 +18,14 @@ import java.io.IOException; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java index 1a6db9ec02..73f01cd854 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java @@ -18,14 +18,14 @@ import java.io.IOException; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java index 5798df7483..9ef1a5bf17 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java @@ -20,6 +20,10 @@ import java.util.Map; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.refresh.RefreshRequest; import org.opensearch.action.index.IndexRequest; @@ -27,10 +31,6 @@ import org.opensearch.common.StopWatch; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.json.JsonXContent; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; @Ignore diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java index 527c8dd85b..ba7582e3f7 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class FlsTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java index 6bdf20f6f3..ac974b8338 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class IndexPatternTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java index 3f895cbdf6..4f222efb3d 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java @@ -16,13 +16,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; public class MFlsTest extends AbstractDlsFlsTest{ diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java index b4fa099bef..12dab5d466 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractRestApiUnitTest.java @@ -21,22 +21,22 @@ import java.util.HashMap; import java.util.Map; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.AuditTestUtils; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.plugins.Plugin; import org.junit.Assert; +import org.opensearch.common.settings.Settings; +import org.opensearch.plugins.Plugin; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.AuditTestUtils; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; public abstract class AbstractRestApiUnitTest extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java index 506a4f4413..2089405281 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiTest.java @@ -16,18 +16,23 @@ package org.opensearch.security.dlic.rest.api; import com.google.common.collect.ImmutableList; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.opensearch.security.securityconf.impl.CType; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiTest.java index 6ba06a79d3..effae8f237 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiTest.java @@ -16,19 +16,20 @@ package org.opensearch.security.dlic.rest.api; import java.util.List; + +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; +import org.junit.Assert; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; + import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionTest.java index 6f66067915..2f29a7c5d3 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionTest.java @@ -15,14 +15,12 @@ package org.opensearch.security.dlic.rest.api; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.AuditTestUtils; -import org.opensearch.security.auditlog.config.AuditConfig; -import org.opensearch.security.compliance.ComplianceConfig; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -32,22 +30,25 @@ import com.google.common.collect.Streams; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.AuditTestUtils; +import org.opensearch.security.auditlog.config.AuditConfig; +import org.opensearch.security.compliance.ComplianceConfig; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; -import static org.opensearch.security.DefaultObjectMapper.writeValueAsString; -import static org.opensearch.security.DefaultObjectMapper.readTree; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.opensearch.security.DefaultObjectMapper.readTree; +import static org.opensearch.security.DefaultObjectMapper.writeValueAsString; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/DashboardsInfoActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/DashboardsInfoActionTest.java index 07a4c27dc7..57d6c7e09c 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/DashboardsInfoActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/DashboardsInfoActionTest.java @@ -16,15 +16,16 @@ package org.opensearch.security.dlic.rest.api; import com.google.common.collect.ImmutableList; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.rest.RestHelper; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.rest.RestHelper; + import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/FlushCacheApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/FlushCacheApiTest.java index e6e1c49d9b..293b36f2c0 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/FlushCacheApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/FlushCacheApiTest.java @@ -15,15 +15,16 @@ package org.opensearch.security.dlic.rest.api; +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.google.common.collect.ImmutableList; + +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/GetConfigurationApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/GetConfigurationApiTest.java index c0a518882a..e980822c50 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/GetConfigurationApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/GetConfigurationApiTest.java @@ -15,17 +15,17 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.google.common.collect.ImmutableList; -import com.fasterxml.jackson.databind.JsonNode; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java index 2ec01dbf97..0474a5bd63 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/IndexMissingTest.java @@ -15,15 +15,15 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.google.common.collect.ImmutableList; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.SecurityJsonNode; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java index fdaf27fc2d..4811947aae 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java @@ -15,30 +15,31 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.auditlog.impl.AuditMessage; -import org.opensearch.security.auditlog.integration.TestAuditlogImpl; -import org.opensearch.security.support.ConfigConstants; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.junit.Assert; -import com.google.common.collect.ImmutableList; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; +import org.opensearch.security.auditlog.integration.TestAuditlogImpl; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluatorTest.java index 900b9cb0e7..c0411277a0 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluatorTest.java @@ -15,17 +15,18 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.nio.file.Path; + +import org.junit.Before; +import org.junit.Test; + +import org.opensearch.common.settings.Settings; +import org.opensearch.rest.RestRequest; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.ssl.transport.PrincipalExtractor; -import org.opensearch.common.settings.Settings; -import org.opensearch.rest.RestRequest; import org.opensearch.threadpool.ThreadPool; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.Path; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RoleBasedAccessTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RoleBasedAccessTest.java index 06155d1a2a..cc40ffe16a 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RoleBasedAccessTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RoleBasedAccessTest.java @@ -15,19 +15,19 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; +import com.google.common.collect.ImmutableList; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.SecurityJsonNode; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java index 7e278cbc93..3de773c4ce 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiTest.java @@ -17,22 +17,22 @@ import java.util.List; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.security.DefaultObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; -import com.fasterxml.jackson.databind.JsonNode; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.support.SecurityJsonNode; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiTest.java index 509b6e5e4f..ef9bca97ef 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiTest.java @@ -17,19 +17,19 @@ import java.util.List; +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityApiAccessTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityApiAccessTest.java index f92f584a42..bef78ebc37 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityApiAccessTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityApiAccessTest.java @@ -15,12 +15,12 @@ package org.opensearch.security.dlic.rest.api; +import com.google.common.collect.ImmutableList; import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiTest.java index 4a42d9c8c1..511a8bfd11 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiTest.java @@ -15,19 +15,19 @@ package org.opensearch.security.dlic.rest.api; +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import com.google.common.collect.ImmutableList; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityHealthActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityHealthActionTest.java index 1501756b57..fcdae45f8f 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityHealthActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityHealthActionTest.java @@ -15,15 +15,16 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.rest.RestHelper; +import com.google.common.collect.ImmutableList; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.google.common.collect.ImmutableList; + +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.rest.RestHelper; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityInfoActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityInfoActionTest.java index 91aa651eb5..ecd29dd3a0 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityInfoActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityInfoActionTest.java @@ -16,15 +16,16 @@ package org.opensearch.security.dlic.rest.api; import com.google.common.collect.ImmutableList; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.rest.RestHelper; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.rest.RestHelper; + import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java index 7c166d66a7..43a5f92b84 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java @@ -16,16 +16,17 @@ package org.opensearch.security.dlic.rest.api; import com.google.common.collect.ImmutableList; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.rest.RestHelper; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.rest.RestHelper; + import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java index e2ca2f1342..a90855fae0 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/UserApiTest.java @@ -15,24 +15,25 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.securityconf.impl.CType; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.file.FileHelper; +import java.net.URLEncoder; +import java.util.List; + +import com.google.common.collect.ImmutableList; import org.apache.http.Header; import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import java.net.URLEncoder; -import com.google.common.collect.ImmutableList; -import java.util.List; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.securityconf.impl.CType; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/WhitelistApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/WhitelistApiTest.java index b7183ebe90..8849331e3a 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/WhitelistApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/WhitelistApiTest.java @@ -16,34 +16,34 @@ package org.opensearch.security.dlic.rest.api; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.auditlog.impl.AuditCategory; -import org.opensearch.security.auditlog.impl.AuditMessage; -import org.opensearch.security.auditlog.integration.TestAuditlogImpl; -import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; -import org.opensearch.security.filter.SecurityRestFilter; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.util.Map; +import java.util.stream.Collectors; + import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.apache.http.Header; import org.apache.http.HttpStatus; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.Map; -import java.util.stream.Collectors; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.auditlog.impl.AuditCategory; +import org.opensearch.security.auditlog.impl.AuditMessage; +import org.opensearch.security.auditlog.integration.TestAuditlogImpl; +import org.opensearch.security.dlic.rest.validation.AbstractConfigurationValidator; +import org.opensearch.security.filter.SecurityRestFilter; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableList; - import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; diff --git a/src/test/java/org/opensearch/security/filter/SecurityFilterTest.java b/src/test/java/org/opensearch/security/filter/SecurityFilterTest.java index 3d002cde53..7f6640098c 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityFilterTest.java +++ b/src/test/java/org/opensearch/security/filter/SecurityFilterTest.java @@ -15,10 +15,21 @@ package org.opensearch.security.filter; +import java.util.Arrays; +import java.util.Collection; + +import com.google.common.collect.ImmutableSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.mockito.ArgumentCaptor; + import org.opensearch.OpenSearchSecurityException; +import org.opensearch.action.ActionListener; +import org.opensearch.action.ActionResponse; +import org.opensearch.cluster.service.ClusterService; +import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AuditLog; -import org.opensearch.security.auth.UserInjector; -import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.CompatConfig; import org.opensearch.security.configuration.DlsFlsRequestValve; @@ -27,30 +38,15 @@ import org.opensearch.security.resolver.IndexResolverReplacer; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; -import com.google.common.collect.ImmutableSet; - -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; -import org.opensearch.client.Client; -import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.threadpool.ThreadPool; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.mockito.ArgumentCaptor; - -import java.util.Arrays; -import java.util.Collection; import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; @RunWith(Parameterized.class) public class SecurityFilterTest { diff --git a/src/test/java/org/opensearch/security/filter/SecurityRestFilterTest.java b/src/test/java/org/opensearch/security/filter/SecurityRestFilterTest.java index 9c1ebd2168..42e93a42ba 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityRestFilterTest.java +++ b/src/test/java/org/opensearch/security/filter/SecurityRestFilterTest.java @@ -15,13 +15,14 @@ package org.opensearch.security.filter; -import org.opensearch.security.dlic.rest.api.AbstractRestApiUnitTest; -import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.opensearch.security.test.helper.rest.RestHelper; import org.apache.http.Header; import org.apache.http.HttpStatus; import org.junit.Test; +import org.opensearch.security.dlic.rest.api.AbstractRestApiUnitTest; +import org.opensearch.security.securityconf.impl.WhitelistingSettings; +import org.opensearch.security.test.helper.rest.RestHelper; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java b/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java index 8409e073f0..ca3e939289 100644 --- a/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java +++ b/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java @@ -29,17 +29,16 @@ */ package org.opensearch.security.http.proxy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.common.collect.ImmutableSet; +import org.junit.Before; +import org.junit.Test; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionListener; import org.opensearch.common.bytes.BytesReference; @@ -52,12 +51,13 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; -import org.junit.Before; -import org.junit.Test; - import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.AuthCredentials; -import com.google.common.collect.ImmutableSet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class HTTPExtendedProxyAuthenticatorTest { diff --git a/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java b/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java index a64d74a750..166fa095d5 100644 --- a/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java +++ b/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java @@ -15,10 +15,10 @@ package org.opensearch.security.httpclient; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; diff --git a/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java b/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java index 4e3e3d5a07..f78d86490c 100644 --- a/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java +++ b/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java @@ -20,6 +20,9 @@ import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; +import org.junit.Assert; +import org.junit.Test; + import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; @@ -29,9 +32,6 @@ import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.junit.Assert; -import org.junit.Test; - import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; diff --git a/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java index 632a89c9bd..79f23037f5 100644 --- a/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java +++ b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java @@ -15,6 +15,7 @@ import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; + import org.opensearch.common.settings.Settings; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.SingleClusterTest; diff --git a/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java b/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java index 8866a248da..4de26329ed 100644 --- a/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java +++ b/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java @@ -34,13 +34,10 @@ import java.util.Arrays; import java.util.List; -import org.opensearch.client.Client; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.SingleClusterTest; -import org.opensearch.security.test.helper.rest.RestHelper; import org.apache.http.Header; import org.apache.http.HttpStatus; +import org.junit.Test; + import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; @@ -49,13 +46,17 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestStatus; -import org.junit.Test; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.SingleClusterTest; +import org.opensearch.security.test.helper.rest.RestHelper; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/opensearch/security/securityconf/impl/v6/ConfigV6Test.java b/src/test/java/org/opensearch/security/securityconf/impl/v6/ConfigV6Test.java index 7d554daf8d..2b87974f9f 100644 --- a/src/test/java/org/opensearch/security/securityconf/impl/v6/ConfigV6Test.java +++ b/src/test/java/org/opensearch/security/securityconf/impl/v6/ConfigV6Test.java @@ -1,6 +1,7 @@ package org.opensearch.security.securityconf.impl.v6; import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -8,8 +9,6 @@ import org.opensearch.security.DefaultObjectMapper; -import com.google.common.collect.ImmutableList; - @RunWith(Parameterized.class) public class ConfigV6Test { private final boolean omitDefaults; diff --git a/src/test/java/org/opensearch/security/securityconf/impl/v7/ConfigV7Test.java b/src/test/java/org/opensearch/security/securityconf/impl/v7/ConfigV7Test.java index c6fc8d89e6..0ec6e6a4e6 100644 --- a/src/test/java/org/opensearch/security/securityconf/impl/v7/ConfigV7Test.java +++ b/src/test/java/org/opensearch/security/securityconf/impl/v7/ConfigV7Test.java @@ -1,6 +1,7 @@ package org.opensearch.security.securityconf.impl.v7; import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.ImmutableList; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -8,8 +9,6 @@ import org.opensearch.security.DefaultObjectMapper; -import com.google.common.collect.ImmutableList; - @RunWith(Parameterized.class) public class ConfigV7Test { private final boolean omitDefaults; diff --git a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java index ba45dad1c0..f1f7f9ea84 100644 --- a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java +++ b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java @@ -30,12 +30,12 @@ import java.util.Collections; import java.util.Date; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.ExceptionsHelper; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Test; +import org.opensearch.ExceptionsHelper; import org.opensearch.security.ssl.util.CertificateValidator; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java index f0ce3b6e6c..790477ffe3 100644 --- a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java @@ -21,8 +21,15 @@ import java.util.Random; import java.util.Set; -import org.opensearch.security.OpenSearchSecurityPlugin; +import io.netty.handler.ssl.OpenSsl; import io.netty.util.internal.PlatformDependent; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; @@ -30,19 +37,12 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.node.Node; import org.opensearch.node.PluginAwareNode; +import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.transport.Netty4Plugin; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import io.netty.handler.ssl.OpenSsl; public class OpenSSLTest extends SSLTest { private static final String USE_NETTY_DEFAULT_ALLOCATOR_PROPERTY = "opensearch.unsafe.use_netty_default_allocator"; diff --git a/src/test/java/org/opensearch/security/ssl/SSLTest.java b/src/test/java/org/opensearch/security/ssl/SSLTest.java index daa8fc3485..d98ee3f3f2 100644 --- a/src/test/java/org/opensearch/security/ssl/SSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/SSLTest.java @@ -17,27 +17,28 @@ package org.opensearch.security.ssl; -import java.net.InetSocketAddress; import java.net.SocketException; import java.nio.file.Paths; -import java.security.KeyStore; import java.security.Security; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; -import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; -import javax.net.ssl.TrustManagerFactory; -import org.opensearch.client.Client; -import org.opensearch.security.OpenSearchSecurityPlugin; +import io.netty.util.internal.PlatformDependent; import org.apache.http.NoHttpResponseException; import org.apache.lucene.util.Constants; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; @@ -45,11 +46,13 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentType; import org.opensearch.node.Node; import org.opensearch.node.PluginAwareNode; +import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.ssl.util.ExceptionUtils; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; @@ -57,13 +60,6 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.transport.Netty4Plugin; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import io.netty.util.internal.PlatformDependent; @SuppressWarnings({"resource", "unchecked"}) public class SSLTest extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/ssl/SecuritySSLCertsInfoActionTests.java b/src/test/java/org/opensearch/security/ssl/SecuritySSLCertsInfoActionTests.java index 0538d5327c..4151374d4e 100644 --- a/src/test/java/org/opensearch/security/ssl/SecuritySSLCertsInfoActionTests.java +++ b/src/test/java/org/opensearch/security/ssl/SecuritySSLCertsInfoActionTests.java @@ -15,20 +15,21 @@ package org.opensearch.security.ssl; -import org.opensearch.security.ssl.util.SSLConfigConstants; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.SingleClusterTest; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.util.List; +import java.util.Map; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import net.minidev.json.JSONObject; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Test; -import java.util.List; -import java.util.Map; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.ssl.util.SSLConfigConstants; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.SingleClusterTest; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; public class SecuritySSLCertsInfoActionTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java b/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java index a9763359b4..9a57a215ba 100644 --- a/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java +++ b/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java @@ -15,25 +15,26 @@ package org.opensearch.security.ssl; -import org.opensearch.security.ssl.util.SSLConfigConstants; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.SingleClusterTest; -import org.opensearch.security.test.helper.cluster.ClusterConfiguration; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.io.File; +import java.util.List; +import java.util.Map; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import net.minidev.json.JSONObject; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import java.io.File; -import java.util.List; -import java.util.Map; +import org.opensearch.common.settings.Settings; +import org.opensearch.security.ssl.util.SSLConfigConstants; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.SingleClusterTest; +import org.opensearch.security.test.helper.cluster.ClusterConfiguration; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; public class SecuritySSLReloadCertsActionTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java b/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java index ca7c3c255d..ab3c0a89c8 100644 --- a/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java +++ b/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java @@ -14,8 +14,10 @@ */ package org.opensearch.security.ssl.transport; -import org.opensearch.security.ssl.SecurityKeyStore; -import org.opensearch.security.ssl.util.SSLConnectionTestUtil; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.PooledByteBufAllocator; @@ -23,15 +25,15 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.handler.ssl.SslHandler; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.ssl.util.SSLConnectionTestUtil; + public class DualModeSSLHandlerTests { public static final int TLS_MAJOR_VERSION = 3; diff --git a/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java b/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java index f52f36090f..825094871a 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java @@ -2,11 +2,11 @@ import java.io.FileNotFoundException; -import org.opensearch.security.test.helper.file.FileHelper; - import org.junit.Assert; import org.junit.Test; +import org.opensearch.security.test.helper.file.FileHelper; + public class CertFromFileTests { @Test diff --git a/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java b/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java index f1a6f3b1db..354d1bc09d 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java @@ -6,11 +6,11 @@ import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; -import org.opensearch.security.test.helper.file.FileHelper; - import org.junit.Assert; import org.junit.Test; +import org.opensearch.security.test.helper.file.FileHelper; + public class CertFromKeystoreTests { @Test diff --git a/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java b/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java index 2ea55c834c..0f0b5e8867 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java @@ -5,11 +5,11 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import org.opensearch.security.test.helper.file.FileHelper; - import org.junit.Assert; import org.junit.Test; +import org.opensearch.security.test.helper.file.FileHelper; + public class CertFromTruststoreTests { @Test diff --git a/src/test/java/org/opensearch/security/ssl/util/SSLConnectionTestUtilTests.java b/src/test/java/org/opensearch/security/ssl/util/SSLConnectionTestUtilTests.java index a8efa0fc3b..c45f75fd09 100644 --- a/src/test/java/org/opensearch/security/ssl/util/SSLConnectionTestUtilTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/SSLConnectionTestUtilTests.java @@ -20,6 +20,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.Socket; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/opensearch/security/support/Base64HelperTest.java b/src/test/java/org/opensearch/security/support/Base64HelperTest.java index d2921b286c..b54b4aef63 100644 --- a/src/test/java/org/opensearch/security/support/Base64HelperTest.java +++ b/src/test/java/org/opensearch/security/support/Base64HelperTest.java @@ -14,14 +14,6 @@ */ package org.opensearch.security.support; -import org.junit.Assert; -import org.junit.Test; - -import org.opensearch.security.user.User; - -import org.opensearch.OpenSearchException; -import org.opensearch.action.search.SearchRequest; - import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -31,6 +23,12 @@ import java.util.regex.Pattern; import com.google.common.io.BaseEncoding; +import org.junit.Assert; +import org.junit.Test; + +import org.opensearch.OpenSearchException; +import org.opensearch.action.search.SearchRequest; +import org.opensearch.security.user.User; import static org.opensearch.security.support.Base64Helper.deserializeObject; import static org.opensearch.security.support.Base64Helper.serializeObject; diff --git a/src/test/java/org/opensearch/security/system_indices/SystemIndicesTests.java b/src/test/java/org/opensearch/security/system_indices/SystemIndicesTests.java index 897a59e5b3..36bdf3be14 100644 --- a/src/test/java/org/opensearch/security/system_indices/SystemIndicesTests.java +++ b/src/test/java/org/opensearch/security/system_indices/SystemIndicesTests.java @@ -15,14 +15,14 @@ package org.opensearch.security.system_indices; -import org.opensearch.client.Client; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.test.DynamicSecurityConfig; -import org.opensearch.security.test.SingleClusterTest; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.rest.RestHelper; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + import org.apache.http.Header; import org.apache.http.HttpStatus; +import org.junit.Test; + import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; import org.opensearch.action.admin.indices.close.CloseIndexRequest; @@ -30,17 +30,18 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest; +import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestStatus; -import org.junit.Test; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.test.DynamicSecurityConfig; +import org.opensearch.security.test.SingleClusterTest; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.rest.RestHelper; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java index 6dcd5dc908..10e59fcfbc 100644 --- a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java +++ b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java @@ -30,68 +30,57 @@ package org.opensearch.security.test; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Joiner; -import com.google.common.collect.Iterators; -import org.apache.http.HttpHost; -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.ssl.SSLContexts; -import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; -import org.opensearch.action.admin.indices.create.CreateIndexRequest; -import org.opensearch.client.*; -import org.opensearch.security.DefaultObjectMapper; -import org.opensearch.security.OpenSearchSecurityPlugin; -import io.netty.handler.ssl.OpenSsl; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; import java.security.KeyStore; -import java.util.Arrays; import java.util.Base64; -import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; +import javax.net.ssl.SSLContext; + +import io.netty.handler.ssl.OpenSsl; import org.apache.http.Header; +import org.apache.http.HttpHost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.message.BasicHeader; -import org.opensearch.security.action.configupdate.ConfigUpdateAction; -import org.opensearch.security.action.configupdate.ConfigUpdateRequest; -import org.opensearch.security.action.configupdate.ConfigUpdateResponse; -import org.opensearch.security.test.helper.cluster.ClusterHelper; -import org.apache.logging.log4j.Logger; +import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.SSLContexts; import org.apache.logging.log4j.LogManager; -import org.opensearch.action.get.GetRequest; +import org.apache.logging.log4j.Logger; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; +import org.junit.rules.TestWatcher; + +import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; +import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; +import org.opensearch.client.Client; +import org.opensearch.client.RestClient; +import org.opensearch.client.RestClientBuilder; +import org.opensearch.client.RestHighLevelClient; import org.opensearch.common.settings.Settings; -import org.opensearch.common.transport.TransportAddress; -import org.opensearch.plugins.Plugin; +import org.opensearch.security.action.configupdate.ConfigUpdateAction; +import org.opensearch.security.action.configupdate.ConfigUpdateRequest; +import org.opensearch.security.action.configupdate.ConfigUpdateResponse; +import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; +import org.opensearch.security.test.helper.cluster.ClusterHelper; import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.test.helper.rules.SecurityTestWatcher; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.Netty4Plugin; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; -import org.junit.rules.TestName; -import org.junit.rules.TestWatcher; - -import org.opensearch.security.securityconf.impl.CType; - -import javax.net.ssl.SSLContext; public abstract class AbstractSecurityUnitTest { diff --git a/src/test/java/org/opensearch/security/test/DynamicSecurityConfig.java b/src/test/java/org/opensearch/security/test/DynamicSecurityConfig.java index 3373119c4d..91a3a79c8b 100644 --- a/src/test/java/org/opensearch/security/test/DynamicSecurityConfig.java +++ b/src/test/java/org/opensearch/security/test/DynamicSecurityConfig.java @@ -36,7 +36,6 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; - import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/test/SingleClusterTest.java b/src/test/java/org/opensearch/security/test/SingleClusterTest.java index 172a91ce24..f3aea12012 100644 --- a/src/test/java/org/opensearch/security/test/SingleClusterTest.java +++ b/src/test/java/org/opensearch/security/test/SingleClusterTest.java @@ -30,18 +30,18 @@ package org.opensearch.security.test; -import org.opensearch.client.Client; -import org.opensearch.common.settings.Settings; +import java.util.List; + import org.junit.After; import org.junit.Assert; +import org.opensearch.client.Client; +import org.opensearch.common.settings.Settings; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.cluster.ClusterHelper; import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.rest.RestHelper; -import java.util.List; - public abstract class SingleClusterTest extends AbstractSecurityUnitTest { private static final int DEFAULT_MASTER_NODE_NUM = 3; diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java index 2546b4e26f..bc3ec819ff 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java @@ -36,17 +36,17 @@ import java.util.List; import java.util.stream.Collectors; -import org.opensearch.security.OpenSearchSecurityPlugin; +import com.google.common.collect.Lists; + import org.opensearch.index.reindex.ReindexPlugin; import org.opensearch.join.ParentJoinPlugin; import org.opensearch.percolator.PercolatorPlugin; import org.opensearch.plugins.Plugin; import org.opensearch.script.mustache.MustachePlugin; import org.opensearch.search.aggregations.matrix.MatrixAggregationPlugin; -import org.opensearch.transport.Netty4Plugin; - +import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.test.plugin.UserInjectorPlugin; -import com.google.common.collect.Lists; +import org.opensearch.transport.Netty4Plugin; public enum ClusterConfiguration { //first one needs to be a master diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java index 6436ab5ace..a7cf2d8249 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java @@ -44,8 +44,9 @@ import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.OpenSearchTimeoutException; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.node.info.NodeInfo; @@ -63,12 +64,11 @@ import org.opensearch.http.HttpInfo; import org.opensearch.node.Node; import org.opensearch.node.PluginAwareNode; +import org.opensearch.security.test.NodeSettingsSupplier; +import org.opensearch.security.test.helper.cluster.ClusterConfiguration.NodeSettings; import org.opensearch.security.test.helper.network.SocketUtils; import org.opensearch.transport.TransportInfo; -import org.opensearch.security.test.helper.cluster.ClusterConfiguration.NodeSettings; -import org.opensearch.security.test.NodeSettingsSupplier; - public final class ClusterHelper { static { diff --git a/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java b/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java index 0e35f21fd6..21f2b35848 100644 --- a/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java @@ -47,8 +47,9 @@ import java.security.KeyStore; import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentBuilder; diff --git a/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java b/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java index 9530622bc7..0ee0c90198 100644 --- a/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java @@ -69,8 +69,8 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/test/plugin/UserInjectorPlugin.java b/src/test/java/org/opensearch/security/test/plugin/UserInjectorPlugin.java index 43e4e8869f..6eacc43768 100644 --- a/src/test/java/org/opensearch/security/test/plugin/UserInjectorPlugin.java +++ b/src/test/java/org/opensearch/security/test/plugin/UserInjectorPlugin.java @@ -34,6 +34,8 @@ import java.util.Map; import java.util.function.Supplier; +import com.google.common.collect.ImmutableMap; + import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -53,8 +55,6 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; -import com.google.common.collect.ImmutableMap; - /** * Mimics the behavior of system integrators that run their own plugins (i.e. server transports) * in front of OpenSearch Security. This transport just copies the user string from the diff --git a/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorTest.java b/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorTest.java index d132cde0ff..66f5c566fe 100644 --- a/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorTest.java +++ b/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorTest.java @@ -15,9 +15,6 @@ package org.opensearch.security.util; -import static org.hamcrest.CoreMatchers.either; -import static org.hamcrest.CoreMatchers.instanceOf; - import java.io.Closeable; import java.io.FileInputStream; import java.io.IOException; @@ -65,7 +62,6 @@ import org.apache.http.ssl.PrivateKeyStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.opensearch.common.settings.Settings; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -73,10 +69,15 @@ import com.amazon.dlic.util.SettingsBasedSSLConfigurator; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfig; + +import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; +import static org.hamcrest.CoreMatchers.either; +import static org.hamcrest.CoreMatchers.instanceOf; + public class SettingsBasedSSLConfiguratorTest { @Rule