From 257c5088e5b777d0a2a78b1bf0ca8f8fafb937e0 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 7 Nov 2023 13:17:08 -0500 Subject: [PATCH] Add import ordering to Spotless formatting rules Signed-off-by: Andriy Redko --- .../bwc/SecurityBackwardsCompatibilityIT.java | 6 +- .../org/opensearch/security/bwc/Song.java | 8 +-- gradle/formatting.gradle | 6 ++ .../security/CrossClusterSearchTests.java | 1 - .../security/DefaultConfigurationTests.java | 1 - .../security/DlsIntegrationTests.java | 1 - .../security/DoNotFailOnForbiddenTests.java | 5 +- .../security/FlsAndFieldMaskingTests.java | 1 - .../IpBruteForceAttacksPreventionTests.java | 5 +- .../security/PointInTimeOperationTest.java | 1 - .../security/ResourceFocusedTests.java | 9 ++- .../security/SearchOperationTest.java | 11 ++-- .../security/SecurityConfigurationTests.java | 1 - .../security/SecurityRolesTests.java | 1 - .../opensearch/security/SnapshotSteps.java | 1 - .../org/opensearch/security/SslOnlyTests.java | 1 - .../org/opensearch/security/TlsTests.java | 2 - .../UserBruteForceAttacksPreventionTests.java | 5 +- .../security/api/CreateResetPasswordTest.java | 1 - .../security/api/DashboardsInfoTest.java | 1 - .../api/DashboardsInfoWithSettingsTest.java | 9 ++- .../http/AnonymousAuthenticationTest.java | 1 - .../opensearch/security/http/AsyncTests.java | 15 +++-- .../security/http/BasicAuthTests.java | 5 +- .../http/BasicAuthWithoutChallengeTests.java | 1 - .../http/CertificateAuthenticationTest.java | 3 +- .../security/http/DisabledBasicAuthTests.java | 3 +- .../http/ExtendedProxyAuthenticationTest.java | 1 - .../security/http/JwtAuthenticationTests.java | 8 +-- .../http/JwtAuthorizationHeaderFactory.java | 7 ++- .../security/http/LdapAuthenticationTest.java | 1 - .../http/LdapStartTlsAuthenticationTest.java | 1 - .../http/LdapTlsAuthenticationTest.java | 1 - .../http/OnBehalfOfJwtAuthenticationTest.java | 13 ++--- .../http/ProxyAuthenticationTest.java | 1 - .../ServiceAccountAuthenticationTest.java | 14 ++--- .../UntrustedLdapServerCertificateTest.java | 1 - .../privileges/PrivilegesEvaluatorTest.java | 1 - .../security/rest/CompressionTests.java | 16 +++--- .../opensearch/security/rest/WhoAmITests.java | 23 ++++---- .../test/framework/OnBehalfOfConfig.java | 1 - .../test/framework/TestSecurityConfig.java | 5 +- .../opensearch/test/framework/XffConfig.java | 1 - .../test/framework/audit/AuditLogsRule.java | 1 - .../framework/audit/TestRuleAuditLogSink.java | 1 - .../framework/certificate/AlgorithmKit.java | 2 +- .../certificate/CertificatesIssuer.java | 2 +- .../framework/certificate/PemConverter.java | 2 +- .../cluster/CloseableHttpClientFactory.java | 1 - .../cluster/ContextHeaderDecoratorClient.java | 4 +- .../test/framework/cluster/LocalCluster.java | 1 - .../cluster/LocalOpenSearchCluster.java | 7 +-- .../cluster/OpenSearchClientProvider.java | 1 - .../test/framework/cluster/SocketUtils.java | 1 - .../framework/cluster/SocketUtilsTests.java | 3 +- .../framework/cluster/TestRestClient.java | 16 +++--- .../cluster/TestRestClientConfiguration.java | 1 - .../framework/ldap/EmbeddedLDAPServer.java | 1 - .../test/framework/ldap/LdapServer.java | 11 ++-- .../framework/log/LogCapturingAppender.java | 22 +++---- .../framework/matcher/AliasExistsMatcher.java | 1 - ...NumberOfAuditsFulfillPredicateMatcher.java | 1 - .../matcher/AuditMessageMatchers.java | 1 - .../AuditsFulfillPredicateMatcher.java | 1 - ...sponseContainExceptionsAtIndexMatcher.java | 1 - .../BulkResponseContainExceptionsMatcher.java | 1 - .../matcher/BulkResponseMatchers.java | 1 - ...usterContainDocumentCountIndexMatcher.java | 1 - .../ClusterContainSuccessSnapshotMatcher.java | 1 - .../ClusterContainTemplateMatcher.java | 1 - ...lusterContainTemplateWithAliasMatcher.java | 1 - .../ClusterContainsDocumentMatcher.java | 1 - ...ContainsDocumentWithFieldValueMatcher.java | 1 - ...sterContainsSnapshotRepositoryMatcher.java | 1 - .../framework/matcher/ClusterMatchers.java | 1 - .../ContainNotEmptyScrollingIdMatcher.java | 1 - ...ainsAggregationWithNameAndTypeMatcher.java | 1 - .../ContainsExactlyIndicesMatcher.java | 1 - .../matcher/ContainsFieldWithTypeMatcher.java | 1 - ...ePitContainsExactlyIdsResponseMatcher.java | 1 - .../matcher/DeleteResponseMatchers.java | 1 - ...NumberOfAuditsFulfillPredicateMatcher.java | 1 - .../matcher/FailureBulkResponseMatcher.java | 1 - .../FieldCapabilitiesResponseMatchers.java | 1 - ...PitsContainsExactlyIdsResponseMatcher.java | 1 - ...etIndexResponseContainsIndicesMatcher.java | 1 - ...appingsResponseContainsIndicesMatcher.java | 1 - ...tResponseContainOnlyDocumentIdMatcher.java | 1 - ...ResponseContainsDocumentWithIdMatcher.java | 1 - ...ContainsExactlyFieldsWithNamesMatcher.java | 1 - ...nseDocumentDoesNotContainFieldMatcher.java | 1 - .../GetResponseDocumentFieldValueMatcher.java | 1 - .../matcher/GetResponseMatchers.java | 1 - ...ettingsResponseContainsIndicesMatcher.java | 1 - .../framework/matcher/IndexExistsMatcher.java | 1 - .../matcher/IndexMappingIsEqualToMatcher.java | 1 - .../matcher/IndexResponseMatchers.java | 1 - .../IndexSettingsContainValuesMatcher.java | 1 - .../matcher/IndexStateIsEqualToMatcher.java | 1 - .../matcher/MultiGetResponseMatchers.java | 1 - .../matcher/MultiSearchResponseMatchers.java | 1 - .../NumberOfFieldsIsEqualToMatcher.java | 1 - ...berOfGetItemResponsesIsEqualToMatcher.java | 1 - .../NumberOfHitsInPageIsEqualToMatcher.java | 1 - ...OfSearchItemResponsesIsEqualToMatcher.java | 1 - .../NumberOfTotalHitsIsEqualToMatcher.java | 1 - .../matcher/OpenSearchExceptionMatchers.java | 1 - .../OpenSearchStatusExceptionMatcher.java | 1 - .../matcher/PitResponseMatchers.java | 1 - ...earchHitContainsFieldWithValueMatcher.java | 1 - .../SearchHitDoesNotContainFieldMatcher.java | 1 - ...earchHitsContainDocumentWithIdMatcher.java | 1 - ...HitsContainDocumentsInAnyOrderMatcher.java | 1 - .../matcher/SearchResponseMatchers.java | 1 - .../SearchResponseWithStatusCodeMatcher.java | 1 - .../SnapshotInClusterDoesNotExist.java | 1 - .../matcher/SuccessBulkResponseMatcher.java | 1 - ...ssfulClearIndicesCacheResponseMatcher.java | 1 - .../SuccessfulCloseIndexResponseMatcher.java | 1 - .../SuccessfulCreateIndexResponseMatcher.java | 1 - .../SuccessfulCreatePitResponseMatcher.java | 1 - .../SuccessfulDeletePitResponseMatcher.java | 1 - .../SuccessfulDeleteResponseMatcher.java | 1 - .../SuccessfulMultiGetResponseMatcher.java | 1 - .../SuccessfulMultiSearchResponseMatcher.java | 1 - .../SuccessfulOpenIndexResponseMatcher.java | 1 - .../SuccessfulResizeResponseMatcher.java | 1 - .../SuccessfulSearchResponseMatcher.java | 1 - .../SuccessfulUpdateResponseMatcher.java | 1 - .../matcher/UpdateResponseMatchers.java | 1 - .../testplugins/AbstractRestHandler.java | 4 +- .../dummy/CustomLegacyTestPlugin.java | 8 +-- .../testplugins/dummy/LegacyRestHandler.java | 4 +- .../dummy/dummyaction/DummyRequest.java | 4 +- .../dummy/dummyaction/DummyResponse.java | 4 +- .../CustomRestProtectedTestPlugin.java | 8 +-- .../ProtectedRoutesRestHandler.java | 1 - .../dummyaction/DummyRequest.java | 4 +- .../dummyaction/DummyResponse.java | 4 +- .../jwt/AbstractHTTPJwtAuthenticator.java | 23 ++++---- .../auth/http/jwt/HTTPJwtAuthenticator.java | 17 +++--- ...TTPJwtKeyByOpenIdConnectAuthenticator.java | 4 +- .../auth/http/jwt/keybyoidc/JwtVerifier.java | 15 ++--- .../http/jwt/keybyoidc/KeySetRetriever.java | 7 +-- .../jwt/keybyoidc/SelfRefreshingKeySet.java | 5 +- .../kerberos/HTTPSpnegoAuthenticator.java | 27 ++++----- .../auth/http/kerberos/util/JaasKrbUtil.java | 1 - .../http/saml/AuthTokenProcessorHandler.java | 36 ++++++------ .../auth/http/saml/HTTPSamlAuthenticator.java | 50 ++++++++-------- .../auth/http/saml/Saml2SettingsProvider.java | 13 ++--- .../saml/SamlFilesystemMetadataResolver.java | 6 +- .../http/saml/SamlHTTPMetadataResolver.java | 9 ++- .../com/amazon/dlic/auth/ldap/LdapUser.java | 9 ++- .../backend/LDAPAuthenticationBackend.java | 23 ++++---- .../backend/LDAPAuthorizationBackend.java | 36 ++++++------ .../dlic/auth/ldap/util/LdapHelper.java | 5 +- .../com/amazon/dlic/auth/ldap/util/Utils.java | 6 +- .../ldap2/LDAPAuthenticationBackend2.java | 27 +++++---- .../auth/ldap2/LDAPAuthorizationBackend2.java | 34 ++++++----- .../ldap2/LDAPConnectionFactoryFactory.java | 11 ++-- .../dlic/auth/ldap2/LDAPUserSearcher.java | 11 ++-- .../dlic/auth/ldap2/MakeJava9Happy.java | 4 +- .../dlic/auth/ldap2/PrivilegedProvider.java | 4 +- .../util/SettingsBasedSSLConfigurator.java | 4 +- .../util/SettingsBasedSSLConfiguratorV4.java | 4 +- .../security/DefaultObjectMapper.java | 1 - .../security/NonValidatingObjectMapper.java | 1 - .../security/OpenSearchSecurityPlugin.java | 57 +++++++++---------- .../TransportConfigUpdateAction.java | 3 +- .../onbehalf/CreateOnBehalfOfTokenAction.java | 5 +- .../action/whoami/TransportWhoAmIAction.java | 2 +- .../security/auditlog/AuditLog.java | 2 +- .../security/auditlog/NullAuditLog.java | 2 +- .../security/auditlog/config/AuditConfig.java | 3 +- .../auditlog/impl/AbstractAuditLog.java | 16 +++--- .../security/auditlog/impl/AuditLogImpl.java | 6 +- .../security/auditlog/impl/AuditMessage.java | 20 +++---- .../auditlog/impl/RequestResolver.java | 9 ++- .../auditlog/routing/AsyncStoragePool.java | 1 - .../auditlog/routing/AuditMessageRouter.java | 5 +- .../security/auditlog/sink/AuditLogSink.java | 10 ++-- .../auditlog/sink/ExternalOpenSearchSink.java | 6 +- .../auditlog/sink/InternalOpenSearchSink.java | 6 +- .../security/auditlog/sink/KafkaSink.java | 1 - .../security/auditlog/sink/Log4JSink.java | 1 - .../security/auditlog/sink/SinkProvider.java | 1 - .../security/auditlog/sink/WebhookSink.java | 1 - .../security/auth/BackendRegistry.java | 9 ++- .../security/auth/RolesInjector.java | 3 +- .../security/auth/UserInjector.java | 5 +- .../HeapBasedClientBlockRegistry.java | 4 +- .../InternalAuthenticationBackend.java | 4 +- .../jwt/EncryptionDecryptionUtil.java | 1 - .../security/authtoken/jwt/JwtVendor.java | 9 ++- .../authtoken/jwt/KeyPaddingUtil.java | 3 +- .../security/compliance/ComplianceConfig.java | 14 ++--- ...mplianceIndexingOperationListenerImpl.java | 3 +- .../compliance/FieldReadCallback.java | 6 +- .../security/configuration/AdminDNs.java | 4 +- .../configuration/ClusterInfoHolder.java | 1 - .../security/configuration/CompatConfig.java | 4 +- .../ConfigurationLoaderSecurity7.java | 5 +- .../ConfigurationRepository.java | 7 +-- .../DlsFilterLevelActionHandler.java | 1 - .../configuration/DlsFlsFilterLeafReader.java | 13 ++--- .../configuration/DlsFlsRequestValve.java | 2 +- .../configuration/DlsFlsValveImpl.java | 7 +-- .../configuration/DlsQueryParser.java | 5 +- .../security/configuration/MaskedField.java | 2 +- .../PrivilegesInterceptorImpl.java | 5 +- .../security/configuration/Salt.java | 3 +- .../SecurityFlsDlsIndexSearcherWrapper.java | 5 +- .../SecurityIndexSearcherWrapper.java | 6 +- .../dlic/rest/api/AbstractApiAction.java | 19 ++++--- .../dlic/rest/api/AccountApiAction.java | 10 ++-- .../dlic/rest/api/ActionGroupsApiAction.java | 10 ++-- .../dlic/rest/api/AllowlistApiAction.java | 6 +- .../dlic/rest/api/AuditApiAction.java | 10 ++-- .../rest/api/AuthTokenProcessorAction.java | 6 +- .../dlic/rest/api/FlushCacheApiAction.java | 6 +- .../dlic/rest/api/InternalUsersApiAction.java | 8 +-- .../dlic/rest/api/MigrateApiAction.java | 10 ++-- .../rest/api/MultiTenancyConfigApiAction.java | 17 +++--- .../dlic/rest/api/NodesDnApiAction.java | 1 - .../dlic/rest/api/PermissionsInfoAction.java | 3 +- .../dlic/rest/api/RequestHandler.java | 16 +++--- .../security/dlic/rest/api/Responses.java | 4 +- .../api/RestApiAdminPrivilegesEvaluator.java | 5 +- .../rest/api/RestApiPrivilegesEvaluator.java | 1 - .../dlic/rest/api/RolesApiAction.java | 14 ++--- .../dlic/rest/api/RolesMappingApiAction.java | 1 - .../rest/api/SecurityConfigApiAction.java | 6 +- .../dlic/rest/api/SecurityConfiguration.java | 6 +- .../dlic/rest/api/SecurityRestApiActions.java | 8 +-- .../rest/api/SecuritySSLCertsApiAction.java | 14 ++--- .../dlic/rest/api/TenantsApiAction.java | 1 - .../dlic/rest/api/ValidateApiAction.java | 8 +-- .../dlic/rest/api/WhitelistApiAction.java | 1 - .../security/dlic/rest/support/Utils.java | 7 +-- .../rest/validation/EndpointValidator.java | 8 +-- .../rest/validation/PasswordValidator.java | 19 ++++--- .../validation/RequestContentValidator.java | 16 +++--- .../rest/validation/ValidationResult.java | 8 +-- .../filter/DelegatingRestHandler.java | 6 +- .../security/filter/NettyRequest.java | 5 +- .../security/filter/NettyRequestChannel.java | 3 +- .../security/filter/OpenSearchRequest.java | 1 - .../security/filter/SecurityFilter.java | 11 ++-- .../security/filter/SecurityRequest.java | 1 - .../filter/SecurityRequestFactory.java | 3 +- .../security/filter/SecurityRestFilter.java | 5 +- .../security/filter/SecurityRestUtils.java | 8 +-- .../security/http/HTTPBasicAuthenticator.java | 1 - .../http/HTTPClientCertAuthenticator.java | 2 - .../security/http/HTTPProxyAuthenticator.java | 1 - .../http/OnBehalfOfAuthenticator.java | 8 +-- .../security/http/RemoteIpDetector.java | 1 - .../http/SecurityHttpServerTransport.java | 3 +- .../SecurityNonSslHttpServerTransport.java | 8 +-- .../opensearch/security/http/XFFResolver.java | 6 +- .../proxy/HTTPExtendedProxyAuthenticator.java | 3 +- .../security/httpclient/HttpClient.java | 4 +- .../identity/SecurityTokenManager.java | 5 +- .../opensaml/integration/CleanerFactory.java | 7 ++- .../integration/SecurityX509CRLImpl.java | 12 ++-- .../SecurityX509CertificateImpl.java | 12 ++-- .../SecurityXMLObjectProviderInitializer.java | 9 +-- .../privileges/PrivilegesEvaluator.java | 10 ++-- .../ProtectedIndexAccessEvaluator.java | 1 - .../RestLayerPrivilegesEvaluator.java | 6 +- .../SecurityIndexAccessEvaluator.java | 12 ++-- .../privileges/SnapshotRestoreEvaluator.java | 1 - .../privileges/TermsAggregationEvaluator.java | 1 - .../resolver/IndexResolverReplacer.java | 6 +- .../security/rest/DashboardsInfoAction.java | 5 +- .../rest/SecurityConfigUpdateAction.java | 3 +- .../security/rest/SecurityHealthAction.java | 3 +- .../security/rest/SecurityInfoAction.java | 7 +-- .../security/rest/SecurityWhoAmIAction.java | 5 +- .../security/rest/TenantInfoAction.java | 7 +-- .../security/securityconf/ConfigModelV6.java | 7 +-- .../security/securityconf/ConfigModelV7.java | 9 ++- .../securityconf/DynamicConfigFactory.java | 12 ++-- .../securityconf/DynamicConfigModel.java | 3 +- .../securityconf/DynamicConfigModelV6.java | 1 - .../securityconf/DynamicConfigModelV7.java | 1 - .../impl/SecurityDynamicConfiguration.java | 1 - .../securityconf/impl/v6/ActionGroupsV6.java | 1 - .../securityconf/impl/v6/ConfigV6.java | 1 - .../securityconf/impl/v6/InternalUserV6.java | 1 - .../securityconf/impl/v6/RoleMappingsV6.java | 1 - .../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 | 1 - .../security/ssl/DefaultSecurityKeyStore.java | 32 +++++------ .../ssl/ExternalSecurityKeyStore.java | 1 - .../ssl/OpenSearchSecuritySSLPlugin.java | 8 +-- .../security/ssl/SecureSSLSettings.java | 3 +- .../security/ssl/SecurityKeyStore.java | 1 - .../netty/Netty4ConditionalDecompressor.java | 4 +- .../Netty4HttpRequestHeaderVerifier.java | 24 ++++---- .../SecuritySSLNettyHttpServerTransport.java | 18 +++--- .../ssl/http/netty/ValidatingDispatcher.java | 4 +- .../ssl/rest/SecuritySSLInfoAction.java | 6 +- .../transport/DefaultPrincipalExtractor.java | 2 - .../ssl/transport/DualModeSSLHandler.java | 13 ++--- .../security/ssl/transport/SSLConfig.java | 1 - .../transport/SecuritySSLNettyTransport.java | 19 +++---- .../transport/SecuritySSLRequestHandler.java | 5 +- .../SecuritySSLTransportInterceptor.java | 1 - .../security/ssl/util/CertFromKeystore.java | 1 - .../ssl/util/SSLCertificateHelper.java | 1 - .../ssl/util/SSLConnectionTestUtil.java | 2 +- .../security/ssl/util/SSLRequestHelper.java | 2 - .../security/support/Base64CustomHelper.java | 11 ++-- .../security/support/Base64JDKHelper.java | 1 - .../security/support/ConfigConstants.java | 1 - .../security/support/ConfigHelper.java | 3 +- .../GuardedSearchOperationWrapper.java | 1 - .../security/support/HeaderHelper.java | 1 - .../security/support/ModuleInfo.java | 8 +-- .../security/support/PemKeyReader.java | 2 - .../security/support/ReflectionHelper.java | 1 - .../support/SafeSerializationUtils.java | 21 +++---- .../security/support/SecurityJsonNode.java | 1 - .../security/support/SecurityUtils.java | 1 - .../support/SnapshotRestoreHelper.java | 1 - .../security/support/StreamableRegistry.java | 1 - .../security/tools/AuditConfigMigrater.java | 3 +- .../opensearch/security/tools/Migrater.java | 3 +- .../security/tools/SecurityAdmin.java | 20 +++---- .../DefaultInterClusterRequestEvaluator.java | 4 +- .../transport/SecurityInterceptor.java | 9 ++- .../transport/SecurityRequestHandler.java | 3 +- .../org/opensearch/security/user/User.java | 1 - .../opensearch/security/user/UserService.java | 4 +- .../opensearch/security/util/KeyUtils.java | 17 +++--- .../ratetracking/HeapBasedRateTracker.java | 4 +- .../http/jwt/HTTPJwtAuthenticatorTest.java | 13 ++--- ...wtKeyByOpenIdConnectAuthenticatorTest.java | 3 +- .../jwt/keybyoidc/KeySetRetrieverTest.java | 8 +-- .../http/jwt/keybyoidc/MockIpdServer.java | 5 +- .../keybyoidc/SelfRefreshingKeySetTest.java | 5 +- ...wtKeyByOpenIdConnectAuthenticatorTest.java | 3 +- .../auth/http/jwt/keybyoidc/TestJwts.java | 3 +- .../http/saml/HTTPSamlAuthenticatorTest.java | 17 +++--- .../auth/http/saml/MockSamlIdpServer.java | 13 ++--- .../dlic/auth/ldap/LdapBackendIntegTest.java | 5 +- .../dlic/auth/ldap/LdapBackendTest.java | 21 ++++--- .../auth/ldap/LdapBackendTestClientCert.java | 7 +-- .../ldap/LdapBackendTestNewStyleConfig.java | 19 +++---- .../amazon/dlic/auth/ldap/srv/LdapServer.java | 12 ++-- .../auth/ldap2/LdapBackendIntegTest2.java | 5 +- .../ldap2/LdapBackendTestClientCert2.java | 7 +-- .../ldap2/LdapBackendTestNewStyleConfig2.java | 23 ++++---- .../ldap2/LdapBackendTestOldStyleConfig2.java | 23 ++++---- .../org/opensearch/node/PluginAwareNode.java | 6 +- .../AdvancedSecurityMigrationTests.java | 1 - .../opensearch/security/AggregationTests.java | 1 - .../org/opensearch/security/ConfigTests.java | 1 - .../security/DataStreamIntegrationTests.java | 1 - .../EncryptionInTransitMigrationTests.java | 1 - .../org/opensearch/security/HealthTests.java | 1 - .../security/HttpIntegrationTests.java | 8 +-- .../security/IndexIntegrationTests.java | 1 - ...exTemplateClusterPermissionsCheckTest.java | 1 - .../InitializationIntegrationTests.java | 1 - .../opensearch/security/IntegrationTests.java | 4 +- .../security/PitIntegrationTests.java | 1 - .../security/PrivilegesEvaluationTest.java | 3 +- .../opensearch/security/ResolveAPITests.java | 1 - .../security/RolesInjectorIntegTest.java | 5 +- .../security/RolesValidationIntegTest.java | 5 +- .../SecurityAdminIEndpointsTests.java | 1 - .../SecurityAdminInvalidConfigsTests.java | 1 - .../security/SecurityAdminTests.java | 1 - .../security/SecurityRolesTests.java | 1 - .../security/SlowIntegrationTests.java | 3 +- .../security/SnapshotRestoreTests.java | 1 - .../security/SystemIntegratorsTests.java | 3 +- .../org/opensearch/security/TaskTests.java | 1 - .../org/opensearch/security/TracingTests.java | 1 - .../TransportUserInjectorIntegTest.java | 5 +- .../security/UserServiceUnitTests.java | 12 ++-- .../org/opensearch/security/UtilTests.java | 3 +- .../auditlog/AbstractAuditlogiUnitTest.java | 6 +- .../security/auditlog/AuditTestUtils.java | 1 - .../compliance/ComplianceAuditlogTest.java | 3 +- .../compliance/ComplianceConfigTest.java | 3 +- .../RestApiComplianceAuditlogTest.java | 1 - .../config/AuditConfigFilterTest.java | 11 ++-- .../config/AuditConfigSerializeTest.java | 9 ++- .../auditlog/config/ThreadPoolConfigTest.java | 1 - .../auditlog/impl/AuditMessageTest.java | 7 +-- .../security/auditlog/impl/AuditlogTest.java | 1 - .../security/auditlog/impl/DelegateTest.java | 1 - .../auditlog/impl/DisabledCategoriesTest.java | 3 +- .../auditlog/impl/IgnoreAuditUsersTest.java | 1 - .../security/auditlog/impl/TracingTests.java | 1 - .../integration/BasicAuditlogTest.java | 3 +- .../auditlog/integration/SSLAuditlogTest.java | 1 - .../auditlog/routing/FallbackTest.java | 1 - .../security/auditlog/routing/PerfTest.java | 1 - .../security/auditlog/routing/RouterTest.java | 1 - .../routing/RoutingConfigurationTest.java | 1 - .../security/auditlog/sink/KafkaSinkTest.java | 4 +- .../auditlog/sink/SinkProviderTLSTest.java | 2 - .../auditlog/sink/SinkProviderTest.java | 1 - .../auditlog/sink/WebhookAuditLogTest.java | 2 - .../auth/InternalAuthBackendTests.java | 4 +- .../security/auth/RolesInjectorTest.java | 3 +- .../security/auth/UserInjectorTest.java | 4 +- .../limiting/AddressBasedRateLimiterTest.java | 5 +- .../limiting/HeapBasedRateTrackerTest.java | 1 - .../UserNameBasedRateLimiterTest.java | 1 - .../authtoken/jwt/AuthTokenUtilsTest.java | 6 +- .../jwt/EncryptionDecryptionUtilsTest.java | 3 +- .../security/authtoken/jwt/JwtVendorTest.java | 8 +-- .../authtoken/jwt/KeyPaddingUtilTest.java | 3 +- .../security/cache/CachingTest.java | 1 - .../ccstest/CrossClusterSearchTests.java | 3 +- .../security/ccstest/RemoteReindexTests.java | 1 - .../security/configuration/SaltTest.java | 3 +- .../dlic/dlsfls/AbstractDlsFlsTest.java | 1 - .../dlic/dlsfls/CCReplicationTest.java | 13 ++--- .../CustomFieldMaskedComplexMappingTest.java | 1 - .../dlic/dlsfls/CustomFieldMaskedTest.java | 1 - .../security/dlic/dlsfls/DateMathTest.java | 1 - .../dlic/dlsfls/DfmOverwritesAllTest.java | 1 - .../security/dlic/dlsfls/DlsDateMathTest.java | 1 - .../dlsfls/DlsFlsCrossClusterSearchTest.java | 1 - .../security/dlic/dlsfls/DlsNestedTest.java | 1 - .../dlic/dlsfls/DlsPropsReplaceTest.java | 1 - .../security/dlic/dlsfls/DlsScrollTest.java | 1 - .../dlic/dlsfls/DlsTermLookupQueryTest.java | 1 - .../dlic/dlsfls/DlsTermsLookupAsserts.java | 1 - .../security/dlic/dlsfls/DlsTest.java | 1 - .../security/dlic/dlsfls/FieldMaskedTest.java | 1 - .../security/dlic/dlsfls/Fls983Test.java | 1 - .../security/dlic/dlsfls/FlsDlsTestAB.java | 1 - .../dlic/dlsfls/FlsDlsTestForbiddenField.java | 1 - .../security/dlic/dlsfls/FlsDlsTestMulti.java | 1 - .../dlic/dlsfls/FlsExistsFieldsTest.java | 1 - .../security/dlic/dlsfls/FlsFieldsTest.java | 1 - .../security/dlic/dlsfls/FlsFieldsWcTest.java | 1 - .../security/dlic/dlsfls/FlsFlatTests.java | 9 +-- .../dlic/dlsfls/FlsIndexingTests.java | 1 - .../security/dlic/dlsfls/FlsKeywordTests.java | 1 - .../security/dlic/dlsfls/FlsPerfTest.java | 1 - .../security/dlic/dlsfls/FlsTest.java | 1 - .../dlic/dlsfls/IndexPatternTest.java | 1 - .../security/dlic/dlsfls/MFlsTest.java | 1 - .../RenameFieldResponseProcessorTest.java | 6 +- .../api/AbstractApiActionValidationTest.java | 11 ++-- .../rest/api/AbstractRestApiUnitTest.java | 1 - ...AccountApiActionConfigValidationsTest.java | 5 +- .../dlic/rest/api/AccountApiTest.java | 3 +- .../ActionGroupsApiActionValidationTest.java | 3 +- .../dlic/rest/api/ActionGroupsApiTest.java | 1 - .../dlic/rest/api/AllowlistApiTest.java | 5 +- ...tApiActionRequestContentValidatorTest.java | 10 ++-- .../dlic/rest/api/AuditApiActionTest.java | 11 ++-- .../api/AuditApiActionValidationTest.java | 4 +- .../rest/api/DashboardsInfoActionTest.java | 1 - .../dlic/rest/api/FlushCacheApiTest.java | 1 - .../rest/api/GetConfigurationApiTest.java | 1 - .../dlic/rest/api/IndexMissingTest.java | 1 - .../InternalUsersApiActionValidationTest.java | 13 +++-- .../rest/api/MultiTenancyConfigApiTest.java | 1 - .../dlic/rest/api/NodesDnApiTest.java | 3 +- .../rest/api/RequestHandlersBuilderTest.java | 13 +++-- .../api/RestApiPrivilegesEvaluatorTest.java | 1 - .../dlic/rest/api/RoleBasedAccessTest.java | 4 +- ...sApiActionRequestContentValidatorTest.java | 4 +- .../api/RolesApiActionValidationTest.java | 3 +- .../security/dlic/rest/api/RolesApiTest.java | 4 +- .../RolesMappingApiActionValidationTest.java | 6 +- .../dlic/rest/api/RolesMappingApiTest.java | 1 - .../rest/api/SecurityConfigApiActionTest.java | 1 - ...SecurityConfigApiActionValidationTest.java | 4 +- .../rest/api/SecurityConfigurationTest.java | 4 +- .../rest/api/SecurityHealthActionTest.java | 1 - .../dlic/rest/api/SecurityInfoActionTest.java | 1 - ...curitySSLCertsApiActionValidationTest.java | 4 +- .../dlic/rest/api/SslCertsApiTest.java | 5 +- .../dlic/rest/api/TenantInfoActionTest.java | 1 - .../security/dlic/rest/api/UserApiTest.java | 4 +- .../dlic/rest/api/WhitelistApiTest.java | 5 +- .../validation/EndpointValidatorTest.java | 11 ++-- .../validation/PasswordValidatorTest.java | 5 +- .../RequestContentValidatorTest.java | 17 +++--- .../filter/DelegatingRestHandlerTests.java | 12 ++-- .../security/filter/RestPathMatchesTests.java | 6 +- .../security/filter/SecurityFilterTests.java | 10 ++-- .../filter/SecurityRestFilterTests.java | 1 - .../filter/SecurityRestFilterUnitTests.java | 4 +- .../filter/SecurityRestUtilsTests.java | 5 +- .../http/OnBehalfOfAuthenticatorTest.java | 27 +++++---- .../HTTPExtendedProxyAuthenticatorTest.java | 9 ++- .../security/httpclient/HttpClientTest.java | 1 - .../identity/SecurityTokenManagerTest.java | 10 ++-- .../multitenancy/test/MultitenancyTests.java | 1 - .../test/TenancyMultitenancyEnabledTests.java | 1 - .../TenancyPrivateTenantEnabledTests.java | 1 - .../privileges/PrivilegesEvaluatorTest.java | 1 - .../PrivilegesEvaluatorUnitTest.java | 10 ++-- .../RestLayerPrivilegesEvaluatorTest.java | 9 +-- .../SecurityIndexAccessEvaluatorTest.java | 20 +++---- .../ProtectedIndicesTests.java | 3 +- .../sanity/tests/SecurityRestTestCase.java | 1 - .../SecurityRolesPermissionsTest.java | 8 +-- .../SecurityRolesPermissionsV6Test.java | 17 +++--- .../securityconf/impl/v6/ConfigV6Test.java | 3 +- .../securityconf/impl/v7/ConfigV7Test.java | 3 +- .../impl/v7/IndexPatternTests.java | 10 ++-- .../setting/DeprecatedSettingsTest.java | 8 +-- .../ssl/CertificateValidatorTest.java | 1 - .../opensearch/security/ssl/OpenSSLTest.java | 8 +-- .../org/opensearch/security/ssl/SSLTest.java | 7 +-- .../security/ssl/SecureSSLSettingsTest.java | 1 - .../SecuritySSLReloadCertsActionTests.java | 10 ++-- .../transport/DualModeSSLHandlerTests.java | 12 ++-- .../security/ssl/util/CertFromFileTests.java | 1 - .../ssl/util/CertFromKeystoreTests.java | 1 - .../ssl/util/CertFromTruststoreTests.java | 1 - .../ssl/util/SSLConnectionTestUtilTests.java | 1 + .../security/ssl/util/TLSUtilTests.java | 5 +- .../support/Base64CustomHelperTest.java | 15 ++--- .../security/support/Base64JDKHelperTest.java | 12 ++-- .../GuardedSearchOperationWrapperTest.java | 1 - .../support/StreamableRegistryTest.java | 4 +- .../AbstractSystemIndicesTests.java | 4 +- .../SystemIndexDisabledTests.java | 4 +- .../SystemIndexPermissionDisabledTests.java | 4 +- .../test/AbstractSecurityUnitTest.java | 9 ++- .../security/test/SingleClusterTest.java | 1 - .../helper/cluster/ClusterConfiguration.java | 1 - .../test/helper/cluster/ClusterHelper.java | 3 +- .../security/test/helper/file/FileHelper.java | 3 +- .../test/helper/network/SocketUtils.java | 1 - .../security/test/helper/rest/RestHelper.java | 2 - .../transport/SecurityInterceptorTests.java | 14 ++--- .../SecuritySSLRequestHandlerTests.java | 5 +- .../SettingsBasedSSLConfiguratorV4Test.java | 8 +-- 548 files changed, 1187 insertions(+), 1566 deletions(-) diff --git a/bwc-test/src/test/java/org/opensearch/security/bwc/SecurityBackwardsCompatibilityIT.java b/bwc-test/src/test/java/org/opensearch/security/bwc/SecurityBackwardsCompatibilityIT.java index 1647dbb132..a26eb5fdd2 100644 --- a/bwc-test/src/test/java/org/opensearch/security/bwc/SecurityBackwardsCompatibilityIT.java +++ b/bwc-test/src/test/java/org/opensearch/security/bwc/SecurityBackwardsCompatibilityIT.java @@ -35,6 +35,7 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Before; +import org.opensearch.Version; import org.opensearch.client.Response; import org.opensearch.client.ResponseException; import org.opensearch.client.RestClient; @@ -45,12 +46,11 @@ import org.opensearch.common.util.io.IOUtils; import org.opensearch.security.bwc.helper.RestHelper; import org.opensearch.test.rest.OpenSearchRestTestCase; -import org.opensearch.Version; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasKey; public class SecurityBackwardsCompatibilityIT extends OpenSearchRestTestCase { diff --git a/bwc-test/src/test/java/org/opensearch/security/bwc/Song.java b/bwc-test/src/test/java/org/opensearch/security/bwc/Song.java index 3cfd2c03e8..3371cbdfac 100644 --- a/bwc-test/src/test/java/org/opensearch/security/bwc/Song.java +++ b/bwc-test/src/test/java/org/opensearch/security/bwc/Song.java @@ -9,14 +9,14 @@ */ package org.opensearch.security.bwc; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.opensearch.common.Randomness; - import java.util.Map; import java.util.Objects; import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.opensearch.common.Randomness; + public class Song { public static final String FIELD_TITLE = "title"; diff --git a/gradle/formatting.gradle b/gradle/formatting.gradle index de52b51c83..76ef15f280 100644 --- a/gradle/formatting.gradle +++ b/gradle/formatting.gradle @@ -6,6 +6,12 @@ allprojects { // non-standard places target '**/*.java' + importOrder( + 'java|javax', + 'com.carrotsearch|com.fasterxml|org.apache|org.awaitility|org.hamcrest|org.junit|com.google|org.bouncycastle|org.opensearch', + '', + '\\#java|\\#org.hamcrest|\\#org.opensearch|\\#' + ) removeUnusedImports() eclipse().configFile rootProject.file('formatter/formatterConfig.xml') trimTrailingWhitespace() diff --git a/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java b/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java index 410ad1c670..b39ef9c86d 100644 --- a/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java +++ b/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java @@ -20,7 +20,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/security/DefaultConfigurationTests.java b/src/integrationTest/java/org/opensearch/security/DefaultConfigurationTests.java index 043d3908e9..ccafc61656 100644 --- a/src/integrationTest/java/org/opensearch/security/DefaultConfigurationTests.java +++ b/src/integrationTest/java/org/opensearch/security/DefaultConfigurationTests.java @@ -21,7 +21,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; diff --git a/src/integrationTest/java/org/opensearch/security/DlsIntegrationTests.java b/src/integrationTest/java/org/opensearch/security/DlsIntegrationTests.java index d1957e50a6..17985dc593 100644 --- a/src/integrationTest/java/org/opensearch/security/DlsIntegrationTests.java +++ b/src/integrationTest/java/org/opensearch/security/DlsIntegrationTests.java @@ -20,7 +20,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; diff --git a/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java b/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java index afbb9f38ae..cb92b4693d 100644 --- a/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java +++ b/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java @@ -21,7 +21,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.fieldcaps.FieldCapabilitiesRequest; import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; @@ -44,13 +43,13 @@ import org.opensearch.test.framework.cluster.LocalCluster; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.aMapWithSize; +import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.arrayContainingInAnyOrder; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.nullValue; import static org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions.Type.ADD; import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; diff --git a/src/integrationTest/java/org/opensearch/security/FlsAndFieldMaskingTests.java b/src/integrationTest/java/org/opensearch/security/FlsAndFieldMaskingTests.java index 4a5460f329..887d217fee 100644 --- a/src/integrationTest/java/org/opensearch/security/FlsAndFieldMaskingTests.java +++ b/src/integrationTest/java/org/opensearch/security/FlsAndFieldMaskingTests.java @@ -25,7 +25,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.fieldcaps.FieldCapabilitiesRequest; import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; diff --git a/src/integrationTest/java/org/opensearch/security/IpBruteForceAttacksPreventionTests.java b/src/integrationTest/java/org/opensearch/security/IpBruteForceAttacksPreventionTests.java index 31f320a654..6ecd98274f 100644 --- a/src/integrationTest/java/org/opensearch/security/IpBruteForceAttacksPreventionTests.java +++ b/src/integrationTest/java/org/opensearch/security/IpBruteForceAttacksPreventionTests.java @@ -15,7 +15,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.AuthFailureListeners; import org.opensearch.test.framework.RateLimiting; import org.opensearch.test.framework.TestSecurityConfig.User; @@ -26,11 +25,11 @@ import org.opensearch.test.framework.cluster.TestRestClientConfiguration; import org.opensearch.test.framework.log.LogsRule; -import static org.apache.http.HttpStatus.SC_OK; -import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL_WITHOUT_CHALLENGE; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; import static org.opensearch.test.framework.cluster.TestRestClientConfiguration.userWithSourceIp; +import static org.apache.http.HttpStatus.SC_OK; +import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/PointInTimeOperationTest.java b/src/integrationTest/java/org/opensearch/security/PointInTimeOperationTest.java index 3d634c4a5d..75eb90672f 100644 --- a/src/integrationTest/java/org/opensearch/security/PointInTimeOperationTest.java +++ b/src/integrationTest/java/org/opensearch/security/PointInTimeOperationTest.java @@ -19,7 +19,6 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.OpenSearchStatusException; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.index.IndexRequest; diff --git a/src/integrationTest/java/org/opensearch/security/ResourceFocusedTests.java b/src/integrationTest/java/org/opensearch/security/ResourceFocusedTests.java index 5d441d0063..aa4b93d612 100644 --- a/src/integrationTest/java/org/opensearch/security/ResourceFocusedTests.java +++ b/src/integrationTest/java/org/opensearch/security/ResourceFocusedTests.java @@ -10,10 +10,6 @@ package org.opensearch.security; -import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; -import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; -import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -23,6 +19,7 @@ import java.util.stream.IntStream; import java.util.zip.GZIPOutputStream; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.io.entity.ByteArrayEntity; @@ -43,7 +40,9 @@ import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; +import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; +import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java b/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java index a38d26800a..df25b63fff 100644 --- a/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java +++ b/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java @@ -15,7 +15,6 @@ import java.util.concurrent.ExecutionException; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.google.common.base.Stopwatch; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.awaitility.Awaitility; @@ -27,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; - +import com.google.common.base.Stopwatch; import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; @@ -86,13 +85,13 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.IndexTemplateMetadata; import org.opensearch.common.settings.Settings; +import org.opensearch.core.rest.RestStatus; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.reindex.BulkByScrollResponse; import org.opensearch.index.reindex.ReindexRequest; import org.opensearch.repositories.RepositoryMissingException; -import org.opensearch.core.rest.RestStatus; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.test.framework.AuditCompliance; import org.opensearch.test.framework.AuditConfiguration; @@ -118,13 +117,13 @@ import static org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions.Type.REMOVE_INDEX; import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.opensearch.client.RequestOptions.DEFAULT; +import static org.opensearch.core.rest.RestStatus.ACCEPTED; +import static org.opensearch.core.rest.RestStatus.FORBIDDEN; +import static org.opensearch.core.rest.RestStatus.INTERNAL_SERVER_ERROR; import static org.opensearch.rest.RestRequest.Method.DELETE; import static org.opensearch.rest.RestRequest.Method.GET; import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.rest.RestRequest.Method.PUT; -import static org.opensearch.core.rest.RestStatus.ACCEPTED; -import static org.opensearch.core.rest.RestStatus.FORBIDDEN; -import static org.opensearch.core.rest.RestStatus.INTERNAL_SERVER_ERROR; import static org.opensearch.security.Song.FIELD_ARTIST; import static org.opensearch.security.Song.FIELD_STARS; import static org.opensearch.security.Song.FIELD_TITLE; diff --git a/src/integrationTest/java/org/opensearch/security/SecurityConfigurationTests.java b/src/integrationTest/java/org/opensearch/security/SecurityConfigurationTests.java index cc95f191f7..508c3a0a05 100644 --- a/src/integrationTest/java/org/opensearch/security/SecurityConfigurationTests.java +++ b/src/integrationTest/java/org/opensearch/security/SecurityConfigurationTests.java @@ -22,7 +22,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; - import org.opensearch.client.Client; import org.opensearch.test.framework.TestSecurityConfig.Role; import org.opensearch.test.framework.TestSecurityConfig.User; diff --git a/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java b/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java index ce2376c616..21cf3288b2 100644 --- a/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java +++ b/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.Role; import org.opensearch.test.framework.cluster.ClusterManager; diff --git a/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java b/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java index 28aa6abd43..08a710b5de 100644 --- a/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java +++ b/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java @@ -13,7 +13,6 @@ import java.util.Map; import org.awaitility.Awaitility; - import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; diff --git a/src/integrationTest/java/org/opensearch/security/SslOnlyTests.java b/src/integrationTest/java/org/opensearch/security/SslOnlyTests.java index 25feffb2b4..ebd8ae8074 100644 --- a/src/integrationTest/java/org/opensearch/security/SslOnlyTests.java +++ b/src/integrationTest/java/org/opensearch/security/SslOnlyTests.java @@ -15,7 +15,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.security.support.ConfigConstants; import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; diff --git a/src/integrationTest/java/org/opensearch/security/TlsTests.java b/src/integrationTest/java/org/opensearch/security/TlsTests.java index de362a544e..7406d2364f 100644 --- a/src/integrationTest/java/org/opensearch/security/TlsTests.java +++ b/src/integrationTest/java/org/opensearch/security/TlsTests.java @@ -12,7 +12,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; - import javax.net.ssl.SSLHandshakeException; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; @@ -25,7 +24,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.test.framework.AuditCompliance; import org.opensearch.test.framework.AuditConfiguration; diff --git a/src/integrationTest/java/org/opensearch/security/UserBruteForceAttacksPreventionTests.java b/src/integrationTest/java/org/opensearch/security/UserBruteForceAttacksPreventionTests.java index cb61950ada..de3c361297 100644 --- a/src/integrationTest/java/org/opensearch/security/UserBruteForceAttacksPreventionTests.java +++ b/src/integrationTest/java/org/opensearch/security/UserBruteForceAttacksPreventionTests.java @@ -16,7 +16,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.AuthFailureListeners; import org.opensearch.test.framework.RateLimiting; import org.opensearch.test.framework.TestSecurityConfig.User; @@ -26,10 +25,10 @@ import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; import org.opensearch.test.framework.log.LogsRule; -import static org.apache.http.HttpStatus.SC_OK; -import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; +import static org.apache.http.HttpStatus.SC_OK; +import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/api/CreateResetPasswordTest.java b/src/integrationTest/java/org/opensearch/security/api/CreateResetPasswordTest.java index 44f8dca20b..724e1a657c 100644 --- a/src/integrationTest/java/org/opensearch/security/api/CreateResetPasswordTest.java +++ b/src/integrationTest/java/org/opensearch/security/api/CreateResetPasswordTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.security.dlic.rest.validation.RequestContentValidator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.test.framework.TestSecurityConfig.User; diff --git a/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoTest.java b/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoTest.java index 8bfcd3b8a8..cc7677de74 100644 --- a/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoTest.java +++ b/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.Role; import org.opensearch.test.framework.cluster.ClusterManager; diff --git a/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoWithSettingsTest.java b/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoWithSettingsTest.java index 7807798210..f60ff23b28 100644 --- a/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoWithSettingsTest.java +++ b/src/integrationTest/java/org/opensearch/security/api/DashboardsInfoWithSettingsTest.java @@ -11,12 +11,9 @@ package org.opensearch.security.api; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; - import java.util.Map; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.http.HttpStatus; import org.junit.ClassRule; import org.junit.Test; @@ -28,7 +25,9 @@ import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/AnonymousAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/AnonymousAuthenticationTest.java index b1c13aeedc..3693183b58 100644 --- a/src/integrationTest/java/org/opensearch/security/http/AnonymousAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/AnonymousAuthenticationTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.RolesMapping; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.cluster.ClusterManager; diff --git a/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java b/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java index ee46fb3905..e8a2f37b8a 100644 --- a/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java @@ -10,8 +10,14 @@ package org.opensearch.security.http; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.hc.core5.http.HttpStatus; import org.junit.ClassRule; import org.junit.Test; @@ -25,13 +31,6 @@ import org.opensearch.test.framework.cluster.TestRestClient; import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; -import java.util.Map; -import java.util.List; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.CompletableFuture; - import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; diff --git a/src/integrationTest/java/org/opensearch/security/http/BasicAuthTests.java b/src/integrationTest/java/org/opensearch/security/http/BasicAuthTests.java index 1e424ab115..3ef0e5605c 100644 --- a/src/integrationTest/java/org/opensearch/security/http/BasicAuthTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/BasicAuthTests.java @@ -17,7 +17,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; import org.opensearch.test.framework.TestSecurityConfig.User; import org.opensearch.test.framework.cluster.ClusterManager; @@ -25,14 +24,14 @@ import org.opensearch.test.framework.cluster.TestRestClient; import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; -import static org.apache.http.HttpStatus.SC_OK; -import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsStringIgnoringCase; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +import static org.apache.http.HttpStatus.SC_OK; +import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/BasicAuthWithoutChallengeTests.java b/src/integrationTest/java/org/opensearch/security/http/BasicAuthWithoutChallengeTests.java index d602d0920b..77a6513d31 100644 --- a/src/integrationTest/java/org/opensearch/security/http/BasicAuthWithoutChallengeTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/BasicAuthWithoutChallengeTests.java @@ -14,7 +14,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; diff --git a/src/integrationTest/java/org/opensearch/security/http/CertificateAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/CertificateAuthenticationTest.java index 975ce25efb..41b2b91b9f 100644 --- a/src/integrationTest/java/org/opensearch/security/http/CertificateAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/CertificateAuthenticationTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.RolesMapping; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.HttpAuthenticator; @@ -29,12 +28,12 @@ import org.opensearch.test.framework.cluster.TestRestClient; import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; -import static org.apache.http.HttpStatus.SC_OK; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasSize; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; +import static org.apache.http.HttpStatus.SC_OK; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/DisabledBasicAuthTests.java b/src/integrationTest/java/org/opensearch/security/http/DisabledBasicAuthTests.java index 1ae3322a1e..31c53a49e0 100644 --- a/src/integrationTest/java/org/opensearch/security/http/DisabledBasicAuthTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/DisabledBasicAuthTests.java @@ -13,16 +13,15 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; -import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; import static org.opensearch.security.http.BasicAuthTests.TEST_USER; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.DISABLED_AUTHC_HTTPBASIC_INTERNAL; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.JWT_AUTH_DOMAIN; +import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/ExtendedProxyAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/ExtendedProxyAuthenticationTest.java index 6fcc7eac83..f305089446 100644 --- a/src/integrationTest/java/org/opensearch/security/http/ExtendedProxyAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/ExtendedProxyAuthenticationTest.java @@ -20,7 +20,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.client.Client; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AuthenticationBackend; diff --git a/src/integrationTest/java/org/opensearch/security/http/JwtAuthenticationTests.java b/src/integrationTest/java/org/opensearch/security/http/JwtAuthenticationTests.java index 9df611e207..13923b50e7 100644 --- a/src/integrationTest/java/org/opensearch/security/http/JwtAuthenticationTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/JwtAuthenticationTests.java @@ -16,8 +16,6 @@ import java.util.Map; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import io.jsonwebtoken.SignatureAlgorithm; -import io.jsonwebtoken.security.Keys; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.message.BasicHeader; import org.junit.BeforeClass; @@ -25,7 +23,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.client.Client; @@ -39,8 +36,10 @@ import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; import org.opensearch.test.framework.log.LogsRule; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; + import static java.nio.charset.StandardCharsets.US_ASCII; -import static org.apache.http.HttpHeaders.AUTHORIZATION; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; @@ -62,6 +61,7 @@ import static org.opensearch.test.framework.matcher.SearchResponseMatchers.numberOfTotalHitsIsEqualTo; import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitContainsFieldWithValue; import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitsContainDocumentWithId; +import static org.apache.http.HttpHeaders.AUTHORIZATION; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/JwtAuthorizationHeaderFactory.java b/src/integrationTest/java/org/opensearch/security/http/JwtAuthorizationHeaderFactory.java index 65d4e7df6f..4b7495fc4f 100644 --- a/src/integrationTest/java/org/opensearch/security/http/JwtAuthorizationHeaderFactory.java +++ b/src/integrationTest/java/org/opensearch/security/http/JwtAuthorizationHeaderFactory.java @@ -16,14 +16,15 @@ import java.util.Map; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableMap; -import io.jsonwebtoken.Jwts; import org.apache.commons.lang3.StringUtils; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.message.BasicHeader; +import com.google.common.collect.ImmutableMap; + +import io.jsonwebtoken.Jwts; -import static io.jsonwebtoken.SignatureAlgorithm.RS256; import static java.util.Objects.requireNonNull; +import static io.jsonwebtoken.SignatureAlgorithm.RS256; class JwtAuthorizationHeaderFactory { public static final String AUDIENCE = "OpenSearch"; diff --git a/src/integrationTest/java/org/opensearch/security/http/LdapAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/LdapAuthenticationTest.java index 299b2cc7d2..0c394d6556 100644 --- a/src/integrationTest/java/org/opensearch/security/http/LdapAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/LdapAuthenticationTest.java @@ -19,7 +19,6 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.junit.runner.RunWith; - import org.opensearch.test.framework.LdapAuthenticationConfigBuilder; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; diff --git a/src/integrationTest/java/org/opensearch/security/http/LdapStartTlsAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/LdapStartTlsAuthenticationTest.java index 395467897d..f07d0e705b 100644 --- a/src/integrationTest/java/org/opensearch/security/http/LdapStartTlsAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/LdapStartTlsAuthenticationTest.java @@ -17,7 +17,6 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.junit.runner.RunWith; - import org.opensearch.test.framework.LdapAuthenticationConfigBuilder; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; diff --git a/src/integrationTest/java/org/opensearch/security/http/LdapTlsAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/LdapTlsAuthenticationTest.java index bac79ffd12..343f34a11c 100644 --- a/src/integrationTest/java/org/opensearch/security/http/LdapTlsAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/LdapTlsAuthenticationTest.java @@ -21,7 +21,6 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.junit.runner.RunWith; - import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/security/http/OnBehalfOfJwtAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/OnBehalfOfJwtAuthenticationTest.java index 1233e23341..e8f0844b76 100644 --- a/src/integrationTest/java/org/opensearch/security/http/OnBehalfOfJwtAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/OnBehalfOfJwtAuthenticationTest.java @@ -18,14 +18,9 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; - import javax.crypto.SecretKey; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.security.Keys; - import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.message.BasicHeader; @@ -43,11 +38,15 @@ import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; + import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.notNullValue; import static org.opensearch.security.support.ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_SECURITYINDEX; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ROLES_ENABLED; diff --git a/src/integrationTest/java/org/opensearch/security/http/ProxyAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/ProxyAuthenticationTest.java index 8d9ede8e5a..4d6e100ce7 100644 --- a/src/integrationTest/java/org/opensearch/security/http/ProxyAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/ProxyAuthenticationTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AuthenticationBackend; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.HttpAuthenticator; diff --git a/src/integrationTest/java/org/opensearch/security/http/ServiceAccountAuthenticationTest.java b/src/integrationTest/java/org/opensearch/security/http/ServiceAccountAuthenticationTest.java index 04f943edcf..8230c52ecb 100644 --- a/src/integrationTest/java/org/opensearch/security/http/ServiceAccountAuthenticationTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/ServiceAccountAuthenticationTest.java @@ -11,6 +11,9 @@ package org.opensearch.security.http; +import java.util.List; +import java.util.Map; + import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.hc.core5.http.HttpStatus; import org.junit.ClassRule; @@ -22,17 +25,14 @@ import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNotNull; -import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_ENABLED_KEY; -import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_PERMISSIONS_ENABLED_KEY; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ROLES_ENABLED; +import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_ENABLED_KEY; import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_KEY; +import static org.opensearch.security.support.ConfigConstants.SECURITY_SYSTEM_INDICES_PERMISSIONS_ENABLED_KEY; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/security/http/UntrustedLdapServerCertificateTest.java b/src/integrationTest/java/org/opensearch/security/http/UntrustedLdapServerCertificateTest.java index 10e3f0853f..d75822ab05 100644 --- a/src/integrationTest/java/org/opensearch/security/http/UntrustedLdapServerCertificateTest.java +++ b/src/integrationTest/java/org/opensearch/security/http/UntrustedLdapServerCertificateTest.java @@ -17,7 +17,6 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.junit.runner.RunWith; - import org.opensearch.test.framework.LdapAuthenticationConfigBuilder; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain; diff --git a/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java b/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java index 2315c979ea..e323919101 100644 --- a/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java +++ b/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java @@ -16,7 +16,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.script.mustache.MustacheModulePlugin; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.TestSecurityConfig.Role; diff --git a/src/integrationTest/java/org/opensearch/security/rest/CompressionTests.java b/src/integrationTest/java/org/opensearch/security/rest/CompressionTests.java index aa747e2586..9227a9464a 100644 --- a/src/integrationTest/java/org/opensearch/security/rest/CompressionTests.java +++ b/src/integrationTest/java/org/opensearch/security/rest/CompressionTests.java @@ -10,8 +10,14 @@ package org.opensearch.security.rest; -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.zip.GZIPOutputStream; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpStatus; @@ -20,20 +26,12 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; - import org.opensearch.test.framework.AsyncActions; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.zip.GZIPOutputStream; - import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; diff --git a/src/integrationTest/java/org/opensearch/security/rest/WhoAmITests.java b/src/integrationTest/java/org/opensearch/security/rest/WhoAmITests.java index 6b72a36277..f00542fe5f 100644 --- a/src/integrationTest/java/org/opensearch/security/rest/WhoAmITests.java +++ b/src/integrationTest/java/org/opensearch/security/rest/WhoAmITests.java @@ -11,8 +11,17 @@ package org.opensearch.security.rest; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import joptsimple.internal.Strings; import org.apache.hc.core5.http.HttpStatus; import org.junit.ClassRule; import org.junit.Rule; @@ -29,21 +38,12 @@ import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; +import joptsimple.internal.Strings; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertTrue; import static org.opensearch.rest.RestRequest.Method.GET; import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; import static org.opensearch.security.auditlog.impl.AuditCategory.MISSING_PRIVILEGES; @@ -51,6 +51,7 @@ import static org.opensearch.test.framework.audit.AuditMessagePredicate.grantedPrivilege; import static org.opensearch.test.framework.audit.AuditMessagePredicate.privilegePredicateRESTLayer; import static org.opensearch.test.framework.audit.AuditMessagePredicate.userAuthenticatedPredicate; +import static org.junit.Assert.assertTrue; @RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) @ThreadLeakScope(ThreadLeakScope.Scope.NONE) diff --git a/src/integrationTest/java/org/opensearch/test/framework/OnBehalfOfConfig.java b/src/integrationTest/java/org/opensearch/test/framework/OnBehalfOfConfig.java index 63e1544f98..0020c19d4a 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/OnBehalfOfConfig.java +++ b/src/integrationTest/java/org/opensearch/test/framework/OnBehalfOfConfig.java @@ -12,7 +12,6 @@ import java.io.IOException; import org.apache.commons.lang3.StringUtils; - import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/integrationTest/java/org/opensearch/test/framework/TestSecurityConfig.java b/src/integrationTest/java/org/opensearch/test/framework/TestSecurityConfig.java index 71a8aad545..ca688b9d33 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/TestSecurityConfig.java +++ b/src/integrationTest/java/org/opensearch/test/framework/TestSecurityConfig.java @@ -47,20 +47,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; - import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.update.UpdateRequest; import org.opensearch.client.Client; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.test.framework.cluster.OpenSearchClientProvider.UserCredentialsHolder; -import static org.apache.http.HttpHeaders.AUTHORIZATION; import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; +import static org.apache.http.HttpHeaders.AUTHORIZATION; /** * This class allows the declarative specification of the security configuration; in particular: diff --git a/src/integrationTest/java/org/opensearch/test/framework/XffConfig.java b/src/integrationTest/java/org/opensearch/test/framework/XffConfig.java index b1c10bfd73..83c77d4766 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/XffConfig.java +++ b/src/integrationTest/java/org/opensearch/test/framework/XffConfig.java @@ -12,7 +12,6 @@ import java.io.IOException; import org.apache.commons.lang3.StringUtils; - import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/integrationTest/java/org/opensearch/test/framework/audit/AuditLogsRule.java b/src/integrationTest/java/org/opensearch/test/framework/audit/AuditLogsRule.java index 3d13d731eb..1f786bd19c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/audit/AuditLogsRule.java +++ b/src/integrationTest/java/org/opensearch/test/framework/audit/AuditLogsRule.java @@ -23,7 +23,6 @@ import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; - import org.opensearch.security.auditlog.impl.AuditMessage; import static java.util.Collections.synchronizedList; diff --git a/src/integrationTest/java/org/opensearch/test/framework/audit/TestRuleAuditLogSink.java b/src/integrationTest/java/org/opensearch/test/framework/audit/TestRuleAuditLogSink.java index c73d57d23c..2c5db0b17e 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/audit/TestRuleAuditLogSink.java +++ b/src/integrationTest/java/org/opensearch/test/framework/audit/TestRuleAuditLogSink.java @@ -11,7 +11,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; diff --git a/src/integrationTest/java/org/opensearch/test/framework/certificate/AlgorithmKit.java b/src/integrationTest/java/org/opensearch/test/framework/certificate/AlgorithmKit.java index 60ae56410c..9f8a5fc560 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/certificate/AlgorithmKit.java +++ b/src/integrationTest/java/org/opensearch/test/framework/certificate/AlgorithmKit.java @@ -34,9 +34,9 @@ import java.security.spec.ECGenParameterSpec; import java.util.function.Supplier; -import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/certificate/CertificatesIssuer.java b/src/integrationTest/java/org/opensearch/test/framework/certificate/CertificatesIssuer.java index 6facf5f2ac..cae1edb1ec 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/certificate/CertificatesIssuer.java +++ b/src/integrationTest/java/org/opensearch/test/framework/certificate/CertificatesIssuer.java @@ -37,9 +37,9 @@ import java.util.Date; import java.util.concurrent.atomic.AtomicLong; -import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.x500.X500Name; import org.bouncycastle.asn1.x500.style.RFC4519Style; diff --git a/src/integrationTest/java/org/opensearch/test/framework/certificate/PemConverter.java b/src/integrationTest/java/org/opensearch/test/framework/certificate/PemConverter.java index 749ab232bc..0a08bb0868 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/certificate/PemConverter.java +++ b/src/integrationTest/java/org/opensearch/test/framework/certificate/PemConverter.java @@ -32,9 +32,9 @@ import java.security.PrivateKey; import java.security.SecureRandom; -import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.base.Strings; import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; import org.bouncycastle.cert.X509CertificateHolder; import org.bouncycastle.openssl.PKCS8Generator; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/CloseableHttpClientFactory.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/CloseableHttpClientFactory.java index ee2f3227e3..0fd75b08a1 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/CloseableHttpClientFactory.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/CloseableHttpClientFactory.java @@ -11,7 +11,6 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; - import javax.net.ssl.SSLContext; import org.apache.hc.client5.http.config.RequestConfig; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java index c6ddf3281a..fed2bfe904 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java @@ -12,15 +12,15 @@ import java.util.Collections; import java.util.Map; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ContextPreservingActionListener; import org.opensearch.client.Client; import org.opensearch.client.FilterClient; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; /** * The class adds provided headers into context before sending request via wrapped {@link Client} diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalCluster.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalCluster.java index 64207ead5b..52366a7e21 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalCluster.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalCluster.java @@ -42,7 +42,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.rules.ExternalResource; - import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.node.PluginAwareNode; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalOpenSearchCluster.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalOpenSearchCluster.java index 189ef79f7c..cbb3a84884 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalOpenSearchCluster.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/LocalOpenSearchCluster.java @@ -47,12 +47,11 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableList; -import com.google.common.net.InetAddresses; import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; +import com.google.common.net.InetAddresses; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.client.AdminClient; import org.opensearch.client.Client; @@ -69,11 +68,11 @@ import org.opensearch.transport.BindTransportException; import static java.util.Objects.requireNonNull; -import static org.junit.Assert.assertEquals; import static org.opensearch.test.framework.cluster.NodeType.CLIENT; import static org.opensearch.test.framework.cluster.NodeType.CLUSTER_MANAGER; import static org.opensearch.test.framework.cluster.NodeType.DATA; import static org.opensearch.test.framework.cluster.PortAllocator.TCP; +import static org.junit.Assert.assertEquals; /** * Encapsulates all the logic to start a local OpenSearch cluster - without any configuration of the security plugin. diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/OpenSearchClientProvider.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/OpenSearchClientProvider.java index ddc68f74df..a57fcc761c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/OpenSearchClientProvider.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/OpenSearchClientProvider.java @@ -40,7 +40,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; - import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtils.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtils.java index 5895829243..3e165b16a3 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtils.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtils.java @@ -33,7 +33,6 @@ import java.util.Random; import java.util.SortedSet; import java.util.TreeSet; - import javax.net.ServerSocketFactory; /** diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtilsTests.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtilsTests.java index fb298c5283..0cffec4c93 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtilsTests.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/SocketUtilsTests.java @@ -31,7 +31,6 @@ import java.net.InetAddress; import java.net.ServerSocket; import java.util.SortedSet; - import javax.net.ServerSocketFactory; import org.junit.Test; @@ -43,9 +42,9 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThrows; import static org.opensearch.test.framework.cluster.SocketUtils.PORT_RANGE_MAX; import static org.opensearch.test.framework.cluster.SocketUtils.PORT_RANGE_MIN; +import static org.junit.Assert.assertThrows; /** * Unit tests for {@link SocketUtils}. diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClient.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClient.java index 55919d814c..e268eca1b6 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClient.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClient.java @@ -28,12 +28,6 @@ package org.opensearch.test.framework.cluster; -import static java.lang.String.format; -import static java.util.Objects.requireNonNull; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; - import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -48,9 +42,10 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.StreamSupport; - import javax.net.ssl.SSLContext; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.io.IOUtils; import org.apache.hc.client5.http.classic.methods.HttpDelete; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -77,8 +72,11 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.security.DefaultObjectMapper; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; +import static java.lang.String.format; +import static java.util.Objects.requireNonNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; /** * A OpenSearch REST client, which is tailored towards use in integration tests. Instances of this class can be diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClientConfiguration.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClientConfiguration.java index 73e61bb1f8..46d225007c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClientConfiguration.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/TestRestClientConfiguration.java @@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.message.BasicHeader; - import org.opensearch.test.framework.cluster.OpenSearchClientProvider.UserCredentialsHolder; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/ldap/EmbeddedLDAPServer.java b/src/integrationTest/java/org/opensearch/test/framework/ldap/EmbeddedLDAPServer.java index 583a0cdaeb..e0056424bb 100755 --- a/src/integrationTest/java/org/opensearch/test/framework/ldap/EmbeddedLDAPServer.java +++ b/src/integrationTest/java/org/opensearch/test/framework/ldap/EmbeddedLDAPServer.java @@ -14,7 +14,6 @@ import java.util.Objects; import org.junit.rules.ExternalResource; - import org.opensearch.test.framework.certificate.CertificateData; public class EmbeddedLDAPServer extends ExternalResource { diff --git a/src/integrationTest/java/org/opensearch/test/framework/ldap/LdapServer.java b/src/integrationTest/java/org/opensearch/test/framework/ldap/LdapServer.java index 18a14242cc..bfbeac0bdb 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/ldap/LdapServer.java +++ b/src/integrationTest/java/org/opensearch/test/framework/ldap/LdapServer.java @@ -27,12 +27,16 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; - import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.test.framework.certificate.CertificateData; +import org.opensearch.test.framework.cluster.SocketUtils; + import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; import com.unboundid.ldap.listener.InMemoryListenerConfig; @@ -42,11 +46,6 @@ import com.unboundid.ldap.sdk.schema.Schema; import com.unboundid.ldif.LDIFReader; import com.unboundid.util.ssl.SSLUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.opensearch.test.framework.certificate.CertificateData; -import org.opensearch.test.framework.cluster.SocketUtils; /** * Based on class com.amazon.dlic.auth.ldap.srv.LdapServer from older tests diff --git a/src/integrationTest/java/org/opensearch/test/framework/log/LogCapturingAppender.java b/src/integrationTest/java/org/opensearch/test/framework/log/LogCapturingAppender.java index 5673f1bd3e..2f369814b9 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/log/LogCapturingAppender.java +++ b/src/integrationTest/java/org/opensearch/test/framework/log/LogCapturingAppender.java @@ -9,8 +9,15 @@ */ package org.opensearch.test.framework.log; -import com.google.common.collect.EvictingQueue; -import com.google.common.collect.Queues; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Core; import org.apache.logging.log4j.core.Filter; @@ -21,15 +28,8 @@ import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.PluginAttribute; import org.apache.logging.log4j.core.config.plugins.PluginFactory; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; +import com.google.common.collect.EvictingQueue; +import com.google.common.collect.Queues; import static org.opensearch.test.framework.log.LogCapturingAppender.PLUGIN_NAME; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/AliasExistsMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/AliasExistsMatcher.java index 42723168ff..a666150853 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/AliasExistsMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/AliasExistsMatcher.java @@ -19,7 +19,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest; import org.opensearch.action.admin.indices.alias.get.GetAliasesResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/AtLeastCertainNumberOfAuditsFulfillPredicateMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/AtLeastCertainNumberOfAuditsFulfillPredicateMatcher.java index ba7feed4c3..533a7d771d 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/AtLeastCertainNumberOfAuditsFulfillPredicateMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/AtLeastCertainNumberOfAuditsFulfillPredicateMatcher.java @@ -13,7 +13,6 @@ import java.util.function.Predicate; import org.hamcrest.Description; - import org.opensearch.security.auditlog.impl.AuditMessage; class AtLeastCertainNumberOfAuditsFulfillPredicateMatcher extends AuditsFulfillPredicateMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditMessageMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditMessageMatchers.java index 080d4473e1..318ae61a57 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditMessageMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditMessageMatchers.java @@ -13,7 +13,6 @@ import java.util.function.Predicate; import org.hamcrest.Matcher; - import org.opensearch.security.auditlog.impl.AuditMessage; public class AuditMessageMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditsFulfillPredicateMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditsFulfillPredicateMatcher.java index 2864c1df81..83361bd261 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditsFulfillPredicateMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/AuditsFulfillPredicateMatcher.java @@ -14,7 +14,6 @@ import java.util.stream.Collectors; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.security.auditlog.impl.AuditMessage; abstract class AuditsFulfillPredicateMatcher extends TypeSafeDiagnosingMatcher> { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsAtIndexMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsAtIndexMatcher.java index 2fb2cc5e74..19e2984912 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsAtIndexMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsAtIndexMatcher.java @@ -12,7 +12,6 @@ import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsMatcher.java index b5e46ba9e2..fdbfc6aeaf 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseContainExceptionsMatcher.java @@ -12,7 +12,6 @@ import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseMatchers.java index eedcd3a3a0..5422a3f4de 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/BulkResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.bulk.BulkResponse; public class BulkResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainDocumentCountIndexMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainDocumentCountIndexMatcher.java index 91d2a28ef8..cdeb2932db 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainDocumentCountIndexMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainDocumentCountIndexMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.get.GetIndexResponse; import org.opensearch.client.Client; import org.opensearch.test.framework.cluster.LocalCluster; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainSuccessSnapshotMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainSuccessSnapshotMatcher.java index 362663e07b..5dca763c04 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainSuccessSnapshotMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainSuccessSnapshotMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateMatcher.java index 119e3a6a2f..ea2188fcfb 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesRequest; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateWithAliasMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateWithAliasMatcher.java index 4addaa0dd5..679107cf12 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateWithAliasMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainTemplateWithAliasMatcher.java @@ -17,7 +17,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesRequest; import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentMatcher.java index 3153214213..fdec84d292 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentMatcher.java @@ -15,7 +15,6 @@ import org.apache.logging.log4j.Logger; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentWithFieldValueMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentWithFieldValueMatcher.java index 21f062fabf..93052e90ae 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentWithFieldValueMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsDocumentWithFieldValueMatcher.java @@ -16,7 +16,6 @@ import org.apache.logging.log4j.Logger; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsSnapshotRepositoryMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsSnapshotRepositoryMatcher.java index fcff8bd6cf..61bca6a04f 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsSnapshotRepositoryMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterContainsSnapshotRepositoryMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterMatchers.java index 3829436d74..bc03ac6e74 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ClusterMatchers.java @@ -12,7 +12,6 @@ import java.util.Map; import org.hamcrest.Matcher; - import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainNotEmptyScrollingIdMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainNotEmptyScrollingIdMatcher.java index 03b9b6bab8..263657161d 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainNotEmptyScrollingIdMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainNotEmptyScrollingIdMatcher.java @@ -12,7 +12,6 @@ import org.apache.commons.lang3.StringUtils; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; class ContainNotEmptyScrollingIdMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsAggregationWithNameAndTypeMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsAggregationWithNameAndTypeMatcher.java index b1ef21c922..eaa3069838 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsAggregationWithNameAndTypeMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsAggregationWithNameAndTypeMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.aggregations.Aggregation; import org.opensearch.search.aggregations.Aggregations; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsExactlyIndicesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsExactlyIndicesMatcher.java index 9b597ad1c8..211f5a4887 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsExactlyIndicesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsExactlyIndicesMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; import static java.util.Objects.isNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsFieldWithTypeMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsFieldWithTypeMatcher.java index cd6b4b05cc..e01510f9df 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsFieldWithTypeMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ContainsFieldWithTypeMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.fieldcaps.FieldCapabilities; import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/DeletePitContainsExactlyIdsResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/DeletePitContainsExactlyIdsResponseMatcher.java index 788d023447..2dba00989b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/DeletePitContainsExactlyIdsResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/DeletePitContainsExactlyIdsResponseMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.DeletePitInfo; import org.opensearch.action.search.DeletePitResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/DeleteResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/DeleteResponseMatchers.java index 4112d0bab8..f85c95a0e9 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/DeleteResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/DeleteResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.delete.DeleteResponse; public class DeleteResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/ExactNumberOfAuditsFulfillPredicateMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/ExactNumberOfAuditsFulfillPredicateMatcher.java index 9bbe966e07..6b4298239b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/ExactNumberOfAuditsFulfillPredicateMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/ExactNumberOfAuditsFulfillPredicateMatcher.java @@ -13,7 +13,6 @@ import java.util.function.Predicate; import org.hamcrest.Description; - import org.opensearch.security.auditlog.impl.AuditMessage; class ExactNumberOfAuditsFulfillPredicateMatcher extends AuditsFulfillPredicateMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/FailureBulkResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/FailureBulkResponseMatcher.java index 3d912e0283..9afedd9abf 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/FailureBulkResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/FailureBulkResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.bulk.BulkResponse; class FailureBulkResponseMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/FieldCapabilitiesResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/FieldCapabilitiesResponseMatchers.java index 2a78c7b71c..1a0707397b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/FieldCapabilitiesResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/FieldCapabilitiesResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; public class FieldCapabilitiesResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetAllPitsContainsExactlyIdsResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetAllPitsContainsExactlyIdsResponseMatcher.java index c568bfa9d7..6983357f1e 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetAllPitsContainsExactlyIdsResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetAllPitsContainsExactlyIdsResponseMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.GetAllPitNodesResponse; import org.opensearch.action.search.ListPitInfo; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetIndexResponseContainsIndicesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetIndexResponseContainsIndicesMatcher.java index 20f02b1319..c024fe8a89 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetIndexResponseContainsIndicesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetIndexResponseContainsIndicesMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.client.indices.GetIndexResponse; import static java.util.Objects.isNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetMappingsResponseContainsIndicesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetMappingsResponseContainsIndicesMatcher.java index 8e2b3da097..5f9adcd22a 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetMappingsResponseContainsIndicesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetMappingsResponseContainsIndicesMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.client.indices.GetMappingsResponse; import org.opensearch.cluster.metadata.MappingMetadata; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainOnlyDocumentIdMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainOnlyDocumentIdMatcher.java index e6d7f02c6e..b460a3fd36 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainOnlyDocumentIdMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainOnlyDocumentIdMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainsDocumentWithIdMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainsDocumentWithIdMatcher.java index aa9d702243..156a3e814e 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainsDocumentWithIdMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseContainsDocumentWithIdMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentContainsExactlyFieldsWithNamesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentContainsExactlyFieldsWithNamesMatcher.java index 66bdc0a9b7..b37af1a293 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentContainsExactlyFieldsWithNamesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentContainsExactlyFieldsWithNamesMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetResponse; import static java.util.Objects.isNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentDoesNotContainFieldMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentDoesNotContainFieldMatcher.java index 508e5b8b61..adc6f59b06 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentDoesNotContainFieldMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentDoesNotContainFieldMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentFieldValueMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentFieldValueMatcher.java index 78bcae5494..09045ce662 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentFieldValueMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseDocumentFieldValueMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.GetResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseMatchers.java index 89c183fc34..2ba19ffc11 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.get.GetResponse; public class GetResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetSettingsResponseContainsIndicesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetSettingsResponseContainsIndicesMatcher.java index c96deef001..0aed96cdd5 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/GetSettingsResponseContainsIndicesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/GetSettingsResponseContainsIndicesMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse; import org.opensearch.common.settings.Settings; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexExistsMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexExistsMatcher.java index aab3d426d2..02c67676ab 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexExistsMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexExistsMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.exists.indices.IndicesExistsRequest; import org.opensearch.action.admin.indices.exists.indices.IndicesExistsResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexMappingIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexMappingIsEqualToMatcher.java index ead0e9d1d7..de1d930c3d 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexMappingIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexMappingIsEqualToMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.mapping.get.GetMappingsRequest; import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexResponseMatchers.java index 88f3ac099d..21b6cab593 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; import org.opensearch.action.admin.indices.open.OpenIndexResponse; import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexSettingsContainValuesMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexSettingsContainValuesMatcher.java index 6bb89c6cae..0c815bd0c1 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexSettingsContainValuesMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexSettingsContainValuesMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest; import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexStateIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexStateIsEqualToMatcher.java index 87270b1388..4a386d881c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexStateIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/IndexStateIsEqualToMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.client.Client; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiGetResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiGetResponseMatchers.java index c2e86b1310..c53a9f87c5 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiGetResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiGetResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.get.MultiGetResponse; public class MultiGetResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiSearchResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiSearchResponseMatchers.java index 9709249d11..2e615b6ccb 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiSearchResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/MultiSearchResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.search.MultiSearchResponse; public class MultiSearchResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfFieldsIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfFieldsIsEqualToMatcher.java index ad8e9725c3..3063485bc0 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfFieldsIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfFieldsIsEqualToMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; class NumberOfFieldsIsEqualToMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfGetItemResponsesIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfGetItemResponsesIsEqualToMatcher.java index 38cfaeb130..830fc1460b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfGetItemResponsesIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfGetItemResponsesIsEqualToMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.MultiGetResponse; class NumberOfGetItemResponsesIsEqualToMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfHitsInPageIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfHitsInPageIsEqualToMatcher.java index 8a25a336f3..2fa3b908d2 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfHitsInPageIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfHitsInPageIsEqualToMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHits; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfSearchItemResponsesIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfSearchItemResponsesIsEqualToMatcher.java index 54bb83cba7..2df2f2e48b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfSearchItemResponsesIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfSearchItemResponsesIsEqualToMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.MultiSearchResponse; class NumberOfSearchItemResponsesIsEqualToMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfTotalHitsIsEqualToMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfTotalHitsIsEqualToMatcher.java index 3f2b379498..73956bd175 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfTotalHitsIsEqualToMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/NumberOfTotalHitsIsEqualToMatcher.java @@ -15,7 +15,6 @@ import org.apache.lucene.search.TotalHits; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHits; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchExceptionMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchExceptionMatchers.java index 6e8519c230..bf1e7dff19 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchExceptionMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchExceptionMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.core.rest.RestStatus; import static org.hamcrest.Matchers.containsString; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchStatusExceptionMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchStatusExceptionMatcher.java index e8efcf151f..56857af74b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchStatusExceptionMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/OpenSearchStatusExceptionMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.OpenSearchException; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/PitResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/PitResponseMatchers.java index 84ab459210..c65cde761d 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/PitResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/PitResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.search.CreatePitResponse; import org.opensearch.action.search.DeletePitResponse; import org.opensearch.action.search.GetAllPitNodesResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitContainsFieldWithValueMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitContainsFieldWithValueMatcher.java index c92924ebfe..335b010ce5 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitContainsFieldWithValueMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitContainsFieldWithValueMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHit; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitDoesNotContainFieldMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitDoesNotContainFieldMatcher.java index 0562acdcbb..34996be4fa 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitDoesNotContainFieldMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitDoesNotContainFieldMatcher.java @@ -13,7 +13,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHit; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentWithIdMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentWithIdMatcher.java index d21df7a578..5eb77fcad5 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentWithIdMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentWithIdMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHit; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentsInAnyOrderMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentsInAnyOrderMatcher.java index 28bf13e321..12e95655e6 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentsInAnyOrderMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchHitsContainDocumentsInAnyOrderMatcher.java @@ -17,7 +17,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseMatchers.java index cf3a6d9e57..73becae342 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseMatchers.java @@ -15,7 +15,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.hamcrest.Matcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.core.rest.RestStatus; import org.opensearch.search.SearchHits; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseWithStatusCodeMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseWithStatusCodeMatcher.java index 5b0f99e11b..c45b4c8818 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseWithStatusCodeMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SearchResponseWithStatusCodeMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SnapshotInClusterDoesNotExist.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SnapshotInClusterDoesNotExist.java index 36e50143f0..8e915adf7a 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SnapshotInClusterDoesNotExist.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SnapshotInClusterDoesNotExist.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.opensearch.client.Client; import org.opensearch.snapshots.SnapshotMissingException; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessBulkResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessBulkResponseMatcher.java index ca4b94d148..cbd362414a 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessBulkResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessBulkResponseMatcher.java @@ -14,7 +14,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulClearIndicesCacheResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulClearIndicesCacheResponseMatcher.java index b70b2c2f9e..0dba3b5925 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulClearIndicesCacheResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulClearIndicesCacheResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCloseIndexResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCloseIndexResponseMatcher.java index 480b7845e9..3513edc3a7 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCloseIndexResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCloseIndexResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.client.indices.CloseIndexResponse; class SuccessfulCloseIndexResponseMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreateIndexResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreateIndexResponseMatcher.java index 810c93e034..40f7c129f7 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreateIndexResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreateIndexResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.client.indices.CreateIndexResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreatePitResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreatePitResponseMatcher.java index 66b59b1526..606f5b7824 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreatePitResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulCreatePitResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.CreatePitResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeletePitResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeletePitResponseMatcher.java index 20906946f1..6bc3218b8c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeletePitResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeletePitResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.DeletePitInfo; import org.opensearch.action.search.DeletePitResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeleteResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeleteResponseMatcher.java index 6c10b2b6f8..775f5f9050 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeleteResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulDeleteResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.delete.DeleteResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiGetResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiGetResponseMatcher.java index fce5d1201c..c0636e996f 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiGetResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiGetResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.get.MultiGetItemResponse; import org.opensearch.action.get.MultiGetResponse; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiSearchResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiSearchResponseMatcher.java index e601f16e8e..753448e432 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiSearchResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulMultiSearchResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.MultiSearchResponse; class SuccessfulMultiSearchResponseMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulOpenIndexResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulOpenIndexResponseMatcher.java index 68389979b1..51962d49b1 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulOpenIndexResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulOpenIndexResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.admin.indices.open.OpenIndexResponse; class SuccessfulOpenIndexResponseMatcher extends TypeSafeDiagnosingMatcher { diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulResizeResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulResizeResponseMatcher.java index 915a0f39bb..93e0a70afb 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulResizeResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulResizeResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.client.indices.ResizeResponse; import static java.util.Objects.requireNonNull; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulSearchResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulSearchResponseMatcher.java index 21017a9014..3fb6dd7d1b 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulSearchResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulSearchResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.search.SearchResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulUpdateResponseMatcher.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulUpdateResponseMatcher.java index 14faab0c4c..2e6ec02d54 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulUpdateResponseMatcher.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/SuccessfulUpdateResponseMatcher.java @@ -11,7 +11,6 @@ import org.hamcrest.Description; import org.hamcrest.TypeSafeDiagnosingMatcher; - import org.opensearch.action.update.UpdateResponse; import org.opensearch.core.rest.RestStatus; diff --git a/src/integrationTest/java/org/opensearch/test/framework/matcher/UpdateResponseMatchers.java b/src/integrationTest/java/org/opensearch/test/framework/matcher/UpdateResponseMatchers.java index ee01fabced..839e79efa4 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/matcher/UpdateResponseMatchers.java +++ b/src/integrationTest/java/org/opensearch/test/framework/matcher/UpdateResponseMatchers.java @@ -10,7 +10,6 @@ package org.opensearch.test.framework.matcher; import org.hamcrest.Matcher; - import org.opensearch.action.update.UpdateResponse; public class UpdateResponseMatchers { diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/AbstractRestHandler.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/AbstractRestHandler.java index 2f88585b22..a068d80e76 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/AbstractRestHandler.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/AbstractRestHandler.java @@ -9,6 +9,8 @@ */ package org.opensearch.test.framework.testplugins; +import java.io.IOException; + import org.opensearch.ExceptionsHelper; import org.opensearch.client.node.NodeClient; import org.opensearch.core.rest.RestStatus; @@ -18,8 +20,6 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; -import java.io.IOException; - public class AbstractRestHandler extends BaseRestHandler { @Override diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/CustomLegacyTestPlugin.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/CustomLegacyTestPlugin.java index 648abef704..afd70f0ba3 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/CustomLegacyTestPlugin.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/CustomLegacyTestPlugin.java @@ -11,6 +11,10 @@ package org.opensearch.test.framework.testplugins.dummy; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + import org.opensearch.action.ActionRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; @@ -28,10 +32,6 @@ import org.opensearch.test.framework.testplugins.dummy.dummyaction.DummyAction; import org.opensearch.test.framework.testplugins.dummy.dummyaction.TransportDummyAction; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - /** * Registers a plugin with legacy routes using {@link org.opensearch.rest.RestHandler.Route} */ diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/LegacyRestHandler.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/LegacyRestHandler.java index e001628596..97ad2a2633 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/LegacyRestHandler.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/LegacyRestHandler.java @@ -11,6 +11,8 @@ package org.opensearch.test.framework.testplugins.dummy; +import java.util.List; + import com.google.common.collect.ImmutableList; import org.opensearch.client.node.NodeClient; import org.opensearch.rest.RestChannel; @@ -20,8 +22,6 @@ import org.opensearch.test.framework.testplugins.dummy.dummyaction.DummyAction; import org.opensearch.test.framework.testplugins.dummy.dummyaction.DummyRequest; -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/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyRequest.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyRequest.java index 5928b4892f..4bd94ae3c4 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyRequest.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyRequest.java @@ -11,14 +11,14 @@ package org.opensearch.test.framework.testplugins.dummy.dummyaction; +import java.io.IOException; + import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import java.io.IOException; - public class DummyRequest extends ActionRequest implements ToXContent { private final String message; diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyResponse.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyResponse.java index e2ee6c9344..c2ac8009fa 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyResponse.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummy/dummyaction/DummyResponse.java @@ -11,6 +11,8 @@ package org.opensearch.test.framework.testplugins.dummy.dummyaction; +import java.io.IOException; + import org.opensearch.common.xcontent.StatusToXContentObject; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; @@ -20,8 +22,6 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import java.io.IOException; - public class DummyResponse extends ActionResponse implements StatusToXContentObject { private final String responseString; diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/CustomRestProtectedTestPlugin.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/CustomRestProtectedTestPlugin.java index 780bee4ac6..d312a351df 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/CustomRestProtectedTestPlugin.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/CustomRestProtectedTestPlugin.java @@ -11,6 +11,10 @@ package org.opensearch.test.framework.testplugins.dummyprotected; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + import org.opensearch.action.ActionRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; @@ -28,10 +32,6 @@ import org.opensearch.test.framework.testplugins.dummyprotected.dummyaction.DummyAction; import org.opensearch.test.framework.testplugins.dummyprotected.dummyaction.TransportDummyAction; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - /** * Registers a plugin with protected routes using {@linkplain org.opensearch.rest.NamedRoute} * This allows authorization against REST layer diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/ProtectedRoutesRestHandler.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/ProtectedRoutesRestHandler.java index 5f20585cd6..765732ee07 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/ProtectedRoutesRestHandler.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/ProtectedRoutesRestHandler.java @@ -15,7 +15,6 @@ import java.util.Set; import com.google.common.collect.ImmutableList; - import org.opensearch.client.node.NodeClient; import org.opensearch.rest.NamedRoute; import org.opensearch.rest.RestChannel; diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyRequest.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyRequest.java index 025d2e1c55..9cc8034dd5 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyRequest.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyRequest.java @@ -11,14 +11,14 @@ package org.opensearch.test.framework.testplugins.dummyprotected.dummyaction; +import java.io.IOException; + import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import java.io.IOException; - public class DummyRequest extends ActionRequest implements ToXContent { private final String message; diff --git a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyResponse.java b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyResponse.java index efd7be49b4..20465f21dc 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyResponse.java +++ b/src/integrationTest/java/org/opensearch/test/framework/testplugins/dummyprotected/dummyaction/DummyResponse.java @@ -11,6 +11,8 @@ package org.opensearch.test.framework.testplugins.dummyprotected.dummyaction; +import java.io.IOException; + import org.opensearch.common.xcontent.StatusToXContentObject; import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; @@ -20,8 +22,6 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import java.io.IOException; - public class DummyResponse extends ActionResponse implements StatusToXContentObject { private final String responseString; 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 da19a808a3..61689f75c4 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 @@ -11,30 +11,20 @@ package com.amazon.dlic.auth.http.jwt; -import static org.apache.http.HttpHeaders.AUTHORIZATION; - import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; import java.text.ParseException; import java.util.Collection; import java.util.Map; -import java.util.Optional; import java.util.Map.Entry; +import java.util.Optional; import java.util.regex.Pattern; -import com.google.common.annotations.VisibleForTesting; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; import org.apache.http.HttpStatus; 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 com.google.common.annotations.VisibleForTesting; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -46,6 +36,15 @@ import org.opensearch.security.filter.SecurityResponse; import org.opensearch.security.user.AuthCredentials; +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 com.nimbusds.jwt.JWTClaimsSet; +import com.nimbusds.jwt.SignedJWT; + +import static org.apache.http.HttpHeaders.AUTHORIZATION; + public abstract class AbstractHTTPJwtAuthenticator implements HTTPAuthenticator { private final static Logger log = LogManager.getLogger(AbstractHTTPJwtAuthenticator.class); 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 1266bc8b04..a087317331 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 @@ -11,26 +11,18 @@ package com.amazon.dlic.auth.http.jwt; -import static org.apache.http.HttpHeaders.AUTHORIZATION; - import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collection; import java.util.Map; -import java.util.Optional; import java.util.Map.Entry; +import java.util.Optional; import java.util.regex.Pattern; -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtParser; -import io.jsonwebtoken.JwtParserBuilder; -import io.jsonwebtoken.security.WeakKeyException; - import org.apache.http.HttpStatus; 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; @@ -41,6 +33,13 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.KeyUtils; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtParser; +import io.jsonwebtoken.JwtParserBuilder; +import io.jsonwebtoken.security.WeakKeyException; + +import static org.apache.http.HttpHeaders.AUTHORIZATION; + 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 808abfc5ea..bf2f82e178 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 @@ -13,11 +13,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 3716eb7997..852b2fba8a 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 @@ -11,24 +11,25 @@ package com.amazon.dlic.auth.http.jwt.keybyoidc; +import java.text.ParseException; +import java.util.Collections; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.base.Strings; + import com.nimbusds.jose.Algorithm; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSVerifier; +import com.nimbusds.jose.crypto.factories.DefaultJWSVerifierFactory; import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.OctetSequenceKey; -import com.nimbusds.jose.crypto.factories.DefaultJWSVerifierFactory; import com.nimbusds.jose.proc.SimpleSecurityContext; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; import com.nimbusds.jwt.proc.BadJWTException; import com.nimbusds.jwt.proc.DefaultJWTClaimsVerifier; -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.text.ParseException; -import java.util.Collections; 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 05f0d88768..bd6e388d08 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 @@ -15,8 +15,6 @@ import java.text.ParseException; import java.util.concurrent.TimeUnit; -import com.nimbusds.jose.jwk.JWKSet; -import joptsimple.internal.Strings; import org.apache.hc.client5.http.cache.HttpCacheContext; import org.apache.hc.client5.http.cache.HttpCacheStorage; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -33,11 +31,12 @@ import org.apache.hc.core5.http.HttpEntity; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.security.DefaultObjectMapper; import com.amazon.dlic.auth.http.jwt.oidc.json.OpenIdProviderConfiguration; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfig; - -import org.opensearch.security.DefaultObjectMapper; +import com.nimbusds.jose.jwk.JWKSet; +import joptsimple.internal.Strings; 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 d1d823e3a8..c47684ee1b 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 @@ -18,11 +18,12 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.base.Strings; + import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.JWKSet; -import org.apache.logging.log4j.LogManager; -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 ad24b8db95..25db5254e3 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 @@ -11,8 +11,6 @@ package com.amazon.dlic.auth.http.kerberos; -import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; - import java.io.Serializable; import java.nio.file.Files; import java.nio.file.Path; @@ -29,24 +27,12 @@ import java.util.Map; import java.util.Optional; import java.util.Set; - import javax.security.auth.Subject; import javax.security.auth.login.LoginException; -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 com.google.common.base.Strings; import org.opensearch.ExceptionsHelper; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -59,6 +45,17 @@ import org.opensearch.security.filter.SecurityResponse; import org.opensearch.security.user.AuthCredentials; +import com.amazon.dlic.auth.http.kerberos.util.JaasKrbUtil; +import com.amazon.dlic.auth.http.kerberos.util.KrbConstants; +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 static org.apache.http.HttpStatus.SC_UNAUTHORIZED; + public class HTTPSpnegoAuthenticator implements HTTPAuthenticator { private static final Oid[] KRB_OIDS = new Oid[] { KrbConstants.SPNEGO, KrbConstants.KRB5MECH }; diff --git a/src/main/java/com/amazon/dlic/auth/http/kerberos/util/JaasKrbUtil.java b/src/main/java/com/amazon/dlic/auth/http/kerberos/util/JaasKrbUtil.java index 619c780027..80894f622b 100644 --- a/src/main/java/com/amazon/dlic/auth/http/kerberos/util/JaasKrbUtil.java +++ b/src/main/java/com/amazon/dlic/auth/http/kerberos/util/JaasKrbUtil.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; - import javax.security.auth.Subject; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; 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 393cedc3b5..b241d8b814 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 @@ -25,45 +25,43 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; - import javax.xml.xpath.XPathExpressionException; 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.nimbusds.jose.JWSAlgorithm; -import com.nimbusds.jose.JWSHeader; -import com.nimbusds.jose.crypto.factories.DefaultJWSSignerFactory; -import com.nimbusds.jose.jwk.JWK; -import com.nimbusds.jose.jwk.KeyUse; -import com.nimbusds.jose.jwk.OctetSequenceKey; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; -import com.onelogin.saml2.authn.SamlResponse; -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.http.HttpStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.joda.time.DateTime; -import org.opensearch.core.common.Strings; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.api.AuthTokenProcessorAction; import org.opensearch.security.filter.SecurityResponse; +import com.nimbusds.jose.JWSAlgorithm; +import com.nimbusds.jose.JWSHeader; +import com.nimbusds.jose.crypto.factories.DefaultJWSSignerFactory; +import com.nimbusds.jose.jwk.JWK; +import com.nimbusds.jose.jwk.KeyUse; +import com.nimbusds.jose.jwk.OctetSequenceKey; +import com.nimbusds.jwt.JWTClaimsSet; +import com.nimbusds.jwt.SignedJWT; +import com.onelogin.saml2.authn.SamlResponse; +import com.onelogin.saml2.exception.ValidationError; +import com.onelogin.saml2.settings.Saml2Settings; +import com.onelogin.saml2.util.Util; +import org.joda.time.DateTime; + import static org.opensearch.security.authtoken.jwt.KeyPaddingUtil.padSecret; class AuthTokenProcessorHandler { 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 fa8db83814..0986832282 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 @@ -23,11 +23,34 @@ import java.util.ServiceLoader; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.http.HttpStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; +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.RestRequest; +import org.opensearch.security.auth.Destroyable; +import org.opensearch.security.auth.HTTPAuthenticator; +import org.opensearch.security.filter.OpenSearchRequest; +import org.opensearch.security.filter.SecurityRequest; +import org.opensearch.security.filter.SecurityRequestChannelUnsupported; +import org.opensearch.security.filter.SecurityResponse; +import org.opensearch.security.opensaml.integration.SecurityXMLObjectProviderInitializer; +import org.opensearch.security.support.ConfigConstants; +import org.opensearch.security.support.PemKeyReader; +import org.opensearch.security.user.AuthCredentials; + +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 com.nimbusds.jose.jwk.JWK; import com.onelogin.saml2.authn.AuthnRequest; import com.onelogin.saml2.logout.LogoutRequest; @@ -37,10 +60,6 @@ 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.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.opensaml.core.config.InitializationException; import org.opensaml.core.config.InitializationService; import org.opensaml.core.config.Initializer; @@ -52,27 +71,6 @@ 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.RestRequest; -import org.opensearch.security.auth.Destroyable; -import org.opensearch.security.auth.HTTPAuthenticator; -import org.opensearch.security.filter.OpenSearchRequest; -import org.opensearch.security.filter.SecurityRequest; -import org.opensearch.security.filter.SecurityRequestChannelUnsupported; -import org.opensearch.security.filter.SecurityResponse; -import org.opensearch.security.opensaml.integration.SecurityXMLObjectProviderInitializer; -import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.support.PemKeyReader; -import org.opensearch.security.user.AuthCredentials; - 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 1b97242762..50a5edc9b7 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 @@ -23,12 +23,16 @@ import java.util.Set; import java.util.stream.Collectors; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; + +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.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.opensaml.core.criterion.EntityIdCriterion; import org.opensaml.saml.metadata.resolver.MetadataResolver; import org.opensaml.saml.metadata.resolver.RefreshableMetadataResolver; @@ -41,11 +45,6 @@ import org.opensaml.xmlsec.signature.X509Certificate; import org.opensaml.xmlsec.signature.X509Data; -import com.amazon.dlic.auth.http.jwt.keybyoidc.AuthenticatorUnavailableException; - -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 302b1f41ea..93d3b020ce 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 @@ -17,12 +17,12 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import net.shibboleth.utilities.java.support.resolver.ResolverException; -import org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver; - 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; + public class SamlFilesystemMetadataResolver extends FilesystemMetadataResolver { SamlFilesystemMetadataResolver(String filePath, Settings opensearchSettings, Path configPath) throws Exception { 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 d68905fe51..ea1394e89b 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 @@ -17,17 +17,16 @@ import java.security.PrivilegedExceptionAction; import java.time.Duration; -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.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver; - -import com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4; - import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; +import com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4; +import net.shibboleth.utilities.java.support.resolver.ResolverException; +import org.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver; + public class SamlHTTPMetadataResolver extends HTTPMetadataResolver { SamlHTTPMetadataResolver(String idpMetadataUrl, Settings opensearchSettings, Path configPath) throws Exception { 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 f752ce4a49..c2f634709e 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/LdapUser.java @@ -16,17 +16,16 @@ import java.util.HashMap; import java.util.Map; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; - -import com.amazon.dlic.auth.ldap.util.Utils; - import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +import com.amazon.dlic.auth.ldap.util.Utils; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; + public class LdapUser extends User { private static final long serialVersionUID = 1L; 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 96cd7a40c9..70a2a071c4 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 @@ -25,18 +25,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.ldaptive.Connection; -import org.ldaptive.ConnectionConfig; -import org.ldaptive.LdapEntry; -import org.ldaptive.ReturnAttributes; -import org.ldaptive.SearchFilter; -import org.ldaptive.SearchScope; - -import com.amazon.dlic.auth.ldap.LdapUser; -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; @@ -44,6 +32,17 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +import com.amazon.dlic.auth.ldap.LdapUser; +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.ldaptive.Connection; +import org.ldaptive.ConnectionConfig; +import org.ldaptive.LdapEntry; +import org.ldaptive.ReturnAttributes; +import org.ldaptive.SearchFilter; +import org.ldaptive.SearchScope; + import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; 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 ac3fd8b32f..cb51dd94f2 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 @@ -35,14 +35,28 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; - import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import com.google.common.collect.HashMultimap; -import io.netty.util.internal.PlatformDependent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.HashMultimap; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.Strings; +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.amazon.dlic.auth.ldap.LdapUser; +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 io.netty.util.internal.PlatformDependent; import org.ldaptive.BindConnectionInitializer; import org.ldaptive.BindRequest; import org.ldaptive.Connection; @@ -67,22 +81,6 @@ import org.ldaptive.ssl.SslConfig; import org.ldaptive.ssl.ThreadLocalTLSSocketFactory; -import com.amazon.dlic.auth.ldap.LdapUser; -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.settings.Settings; -import org.opensearch.core.common.Strings; -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 static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_PASSWORD; import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_TRUSTSTORE_PASSWORD; 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 f06c7d59d7..f2dffa62fd 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 @@ -16,11 +16,12 @@ import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; - import javax.naming.InvalidNameException; 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; @@ -33,8 +34,6 @@ 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 743705eee5..7c96602e47 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 @@ -23,12 +23,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.ldaptive.Connection; -import org.ldaptive.LdapAttribute; - import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; +import org.ldaptive.Connection; +import org.ldaptive.LdapAttribute; + 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 74184de0eb..cf371ad62d 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java @@ -23,6 +23,19 @@ 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; +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 com.amazon.dlic.auth.ldap.LdapUser; +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.ldaptive.BindRequest; import org.ldaptive.Connection; import org.ldaptive.ConnectionFactory; @@ -33,20 +46,6 @@ import org.ldaptive.ReturnAttributes; import org.ldaptive.pool.ConnectionPool; -import com.amazon.dlic.auth.ldap.LdapUser; -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; - public class LDAPAuthenticationBackend2 implements AuthenticationBackend, Destroyable { protected static final Logger log = LogManager.getLogger(LDAPAuthenticationBackend2.class); 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 d8d27de7da..25073ba625 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java @@ -24,29 +24,12 @@ import java.util.List; import java.util.Map; import java.util.Set; - import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import com.google.common.collect.HashMultimap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.ldaptive.Connection; -import org.ldaptive.ConnectionFactory; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.LdapException; -import org.ldaptive.ReturnAttributes; -import org.ldaptive.SearchFilter; -import org.ldaptive.SearchScope; -import org.ldaptive.pool.ConnectionPool; - -import com.amazon.dlic.auth.ldap.LdapUser; -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 com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; - +import com.google.common.collect.HashMultimap; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -57,6 +40,21 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +import com.amazon.dlic.auth.ldap.LdapUser; +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 com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; +import org.ldaptive.Connection; +import org.ldaptive.ConnectionFactory; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.LdapException; +import org.ldaptive.ReturnAttributes; +import org.ldaptive.SearchFilter; +import org.ldaptive.SearchScope; +import org.ldaptive.pool.ConnectionPool; + public class LDAPAuthorizationBackend2 implements AuthorizationBackend, Destroyable { static final int ZERO_PLACEHOLDER = 0; 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 877c4160da..2b9fd9f7b3 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java @@ -20,6 +20,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.common.settings.Settings; + +import com.amazon.dlic.auth.ldap.util.ConfigConstants; +import com.amazon.dlic.util.SettingsBasedSSLConfigurator; +import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; import org.ldaptive.ActivePassiveConnectionStrategy; import org.ldaptive.BindConnectionInitializer; import org.ldaptive.CompareRequest; @@ -56,12 +61,6 @@ import org.ldaptive.ssl.CredentialConfigFactory; import org.ldaptive.ssl.SslConfig; -import com.amazon.dlic.auth.ldap.util.ConfigConstants; -import com.amazon.dlic.util.SettingsBasedSSLConfigurator; -import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfigException; - -import org.opensearch.common.settings.Settings; - import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; public class LDAPConnectionFactoryFactory { 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 966555daff..a9d26e736f 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java @@ -21,16 +21,15 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.ldaptive.Connection; -import org.ldaptive.LdapEntry; -import org.ldaptive.SearchFilter; -import org.ldaptive.SearchScope; +import org.opensearch.common.settings.Settings; 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.common.settings.Settings; +import org.ldaptive.Connection; +import org.ldaptive.LdapEntry; +import org.ldaptive.SearchFilter; +import org.ldaptive.SearchScope; 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 63e88fd2d4..67bf49cfd7 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/MakeJava9Happy.java @@ -15,11 +15,11 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import org.opensearch.SpecialPermission; + import io.netty.util.internal.PlatformDependent; import org.ldaptive.ssl.ThreadLocalTLSSocketFactory; -import org.opensearch.SpecialPermission; - public class MakeJava9Happy { private static ClassLoader classLoader; 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 7ca4a4ff2e..8f9a18c758 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/PrivilegedProvider.java @@ -15,6 +15,8 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import org.opensearch.SpecialPermission; + import org.ldaptive.AddRequest; import org.ldaptive.BindRequest; import org.ldaptive.CompareRequest; @@ -35,8 +37,6 @@ 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 ed42117a04..13d7c400be 100644 --- a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java +++ b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; @@ -33,7 +32,6 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -import com.google.common.collect.ImmutableList; import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; @@ -43,7 +41,7 @@ import org.apache.hc.core5.ssl.SSLContexts; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.PemKeyReader; diff --git a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfiguratorV4.java b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfiguratorV4.java index c2de5d95a2..385bedffbc 100644 --- a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfiguratorV4.java +++ b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfiguratorV4.java @@ -26,14 +26,12 @@ import java.util.Collection; import java.util.List; import java.util.Map; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; 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; @@ -44,7 +42,7 @@ import org.apache.http.ssl.SSLContexts; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.security.support.PemKeyReader; diff --git a/src/main/java/org/opensearch/security/DefaultObjectMapper.java b/src/main/java/org/opensearch/security/DefaultObjectMapper.java index f8564cb21b..0f776200cc 100644 --- a/src/main/java/org/opensearch/security/DefaultObjectMapper.java +++ b/src/main/java/org/opensearch/security/DefaultObjectMapper.java @@ -47,7 +47,6 @@ 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 { diff --git a/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java b/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java index e0b34b3da1..de6a2da7d1 100644 --- a/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java +++ b/src/main/java/org/opensearch/security/NonValidatingObjectMapper.java @@ -38,7 +38,6 @@ 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 { diff --git a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java index de7693e393..5a4356fc8b 100644 --- a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java +++ b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java @@ -28,12 +28,39 @@ // CS-SUPPRESS-SINGLE: RegexpSingleline Extensions manager used to allow/disallow TLS connections to extensions -import com.google.common.collect.Lists; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.attribute.PosixFilePermission; +import java.security.AccessController; +import java.security.MessageDigest; +import java.security.PrivilegedAction; +import java.security.Security; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; +import java.util.stream.Stream; 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 com.google.common.collect.Lists; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; @@ -173,34 +200,6 @@ import org.opensearch.transport.TransportService; import org.opensearch.watcher.ResourceWatcherService; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.nio.file.attribute.PosixFilePermission; -import java.security.AccessController; -import java.security.MessageDigest; -import java.security.PrivilegedAction; -import java.security.Security; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.ENDPOINTS_WITH_PERMISSIONS; import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.SECURITY_CONFIG_UPDATE; import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; 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 1e5b5e4056..7eb5e186c9 100644 --- a/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java +++ b/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java @@ -31,16 +31,15 @@ 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.TransportNodesAction; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.inject.Provider; +import org.opensearch.common.settings.Settings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.BackendRegistry; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.securityconf.DynamicConfigFactory; diff --git a/src/main/java/org/opensearch/security/action/onbehalf/CreateOnBehalfOfTokenAction.java b/src/main/java/org/opensearch/security/action/onbehalf/CreateOnBehalfOfTokenAction.java index 0863fee552..fbbbab8764 100644 --- a/src/main/java/org/opensearch/security/action/onbehalf/CreateOnBehalfOfTokenAction.java +++ b/src/main/java/org/opensearch/security/action/onbehalf/CreateOnBehalfOfTokenAction.java @@ -16,11 +16,11 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; import org.opensearch.client.node.NodeClient; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.identity.tokens.OnBehalfOfClaims; import org.opensearch.rest.BaseRestHandler; @@ -28,7 +28,6 @@ import org.opensearch.rest.NamedRoute; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.identity.SecurityTokenManager; import static org.opensearch.rest.RestRequest.Method.POST; 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 f7e741b868..4bc6238765 100644 --- a/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java +++ b/src/main/java/org/opensearch/security/action/whoami/TransportWhoAmIAction.java @@ -26,12 +26,12 @@ package org.opensearch.security.action.whoami; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.settings.Settings; +import org.opensearch.core.action.ActionListener; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.HeaderHelper; diff --git a/src/main/java/org/opensearch/security/auditlog/AuditLog.java b/src/main/java/org/opensearch/security/auditlog/AuditLog.java index 997b9e4b87..45eb8cd1e6 100644 --- a/src/main/java/org/opensearch/security/auditlog/AuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/AuditLog.java @@ -29,12 +29,12 @@ import java.io.Closeable; import java.util.Map; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; import org.opensearch.index.engine.Engine.Index; import org.opensearch.index.engine.Engine.IndexResult; import org.opensearch.index.get.GetResult; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.filter.SecurityRequest; diff --git a/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java b/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java index 1ac4492a94..cff4157250 100644 --- a/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/NullAuditLog.java @@ -29,12 +29,12 @@ import java.io.IOException; import java.util.Map; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; import org.opensearch.index.engine.Engine.Index; import org.opensearch.index.engine.Engine.IndexResult; import org.opensearch.index.get.GetResult; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.filter.SecurityRequest; 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 f6f9a42e87..ae6b3f2cf9 100644 --- a/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java +++ b/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java @@ -22,12 +22,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; +import org.apache.logging.log4j.Logger; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; 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 org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.impl.AuditCategory; 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 a395327f42..057a1c83ff 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java @@ -27,13 +27,11 @@ import java.util.stream.Collectors; 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.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.annotations.VisibleForTesting; +import com.google.common.io.BaseEncoding; import org.opensearch.SpecialPermission; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkShardRequest; @@ -42,14 +40,15 @@ import org.opensearch.action.update.UpdateRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.xcontent.MediaType; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.transport.TransportAddress; +import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -59,7 +58,6 @@ import org.opensearch.index.engine.Engine.Index; import org.opensearch.index.engine.Engine.IndexResult; import org.opensearch.index.get.GetResult; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.config.AuditConfig; @@ -73,6 +71,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; +import com.flipkart.zjsonpatch.JsonDiff; + import static org.opensearch.core.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; public abstract class AbstractAuditLog implements AuditLog { 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 8da4b13d4c..e860ec0d5e 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AuditLogImpl.java @@ -17,20 +17,18 @@ import java.security.PrivilegedAction; import java.util.Map; -import org.greenrobot.eventbus.Subscribe; - import org.opensearch.SpecialPermission; 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.core.index.shard.ShardId; import org.opensearch.env.Environment; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; import org.opensearch.index.engine.Engine.Index; import org.opensearch.index.engine.Engine.IndexResult; import org.opensearch.index.get.GetResult; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.auditlog.routing.AuditMessageRouter; import org.opensearch.security.filter.SecurityRequest; @@ -38,6 +36,8 @@ 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 a41b4625c2..6642661a63 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AuditMessage.java @@ -24,35 +24,35 @@ import java.util.Objects; import java.util.regex.Pattern; -import com.google.common.annotations.VisibleForTesting; import org.apache.commons.codec.digest.DigestUtils; import org.apache.hc.core5.net.URIBuilder; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - +import com.google.common.annotations.VisibleForTesting; import org.opensearch.ExceptionsHelper; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.xcontent.MediaType; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.Strings; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.rest.RestRequest; 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.filter.SecurityRequest; import org.opensearch.security.filter.OpenSearchRequest; +import org.opensearch.security.filter.SecurityRequest; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.support.WildcardMatcher; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + 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 8a1177ec60..f58daf4db3 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java @@ -22,7 +22,6 @@ 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; @@ -41,15 +40,15 @@ import org.opensearch.action.update.UpdateRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.core.xcontent.MediaType; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.reindex.DeleteByQueryRequest; import org.opensearch.index.reindex.ReindexRequest; import org.opensearch.index.reindex.UpdateByQueryRequest; 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 494d67aba6..a02d6c2a87 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java @@ -18,7 +18,6 @@ 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 b56ac42a2a..4ac92091f0 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java @@ -17,11 +17,10 @@ import java.util.List; import java.util.Map; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Maps; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Maps; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.config.ThreadPoolConfig; 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 a482b81c29..c6f72807e5 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java @@ -15,17 +15,17 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; -import com.google.common.util.concurrent.Uninterruptibles; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormatter; - +import com.google.common.util.concurrent.Uninterruptibles; import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.support.ConfigConstants; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormatter; + public abstract class AuditLogSink { protected final Logger log = LogManager.getLogger(this.getClass()); 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 f3a8d288f8..7bde676399 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/ExternalOpenSearchSink.java @@ -20,9 +20,6 @@ import java.util.Collections; import java.util.List; -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; @@ -31,6 +28,9 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.PemKeyReader; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_PASSWORD; import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_TRUSTSTORE_PASSWORD; 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 f01051c70f..dd1db488da 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/InternalOpenSearchSink.java @@ -14,9 +14,6 @@ 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; @@ -28,6 +25,9 @@ import org.opensearch.security.support.HeaderHelper; import org.opensearch.threadpool.ThreadPool; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + public final class InternalOpenSearchSink extends AuditLogSink { private final Client clientProvider; 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 e67ed66549..533cd762c8 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/KafkaSink.java @@ -25,7 +25,6 @@ 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; 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 f01043fa21..6d37f2e8fb 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java @@ -14,7 +14,6 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; 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 894c9162dd..f47d87ac17 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java @@ -18,7 +18,6 @@ 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.security.dlic.rest.support.Utils; 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 8616fa9df5..9c8d0188cd 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/WebhookSink.java @@ -21,7 +21,6 @@ import java.security.PrivilegedAction; import java.security.cert.X509Certificate; import java.util.concurrent.TimeUnit; - import javax.net.ssl.SSLContext; import org.apache.hc.client5.http.classic.methods.HttpGet; diff --git a/src/main/java/org/opensearch/security/auth/BackendRegistry.java b/src/main/java/org/opensearch/security/auth/BackendRegistry.java index a064207964..00db15e81e 100644 --- a/src/main/java/org/opensearch/security/auth/BackendRegistry.java +++ b/src/main/java/org/opensearch/security/auth/BackendRegistry.java @@ -38,17 +38,14 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +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.util.concurrent.ThreadContext; @@ -68,6 +65,8 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; +import org.greenrobot.eventbus.Subscribe; + import static org.apache.http.HttpStatus.SC_FORBIDDEN; import static org.apache.http.HttpStatus.SC_SERVICE_UNAVAILABLE; import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; diff --git a/src/main/java/org/opensearch/security/auth/RolesInjector.java b/src/main/java/org/opensearch/security/auth/RolesInjector.java index 6c0eaa0732..ffbfab52cb 100644 --- a/src/main/java/org/opensearch/security/auth/RolesInjector.java +++ b/src/main/java/org/opensearch/security/auth/RolesInjector.java @@ -17,11 +17,10 @@ import java.util.Set; -import com.google.common.collect.ImmutableSet; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableSet; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.support.ConfigConstants; diff --git a/src/main/java/org/opensearch/security/auth/UserInjector.java b/src/main/java/org/opensearch/security/auth/UserInjector.java index 351afde0f1..f60fdf95fc 100644 --- a/src/main/java/org/opensearch/security/auth/UserInjector.java +++ b/src/main/java/org/opensearch/security/auth/UserInjector.java @@ -34,13 +34,12 @@ import java.util.HashMap; import java.util.Map; -import com.google.common.base.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.base.Strings; +import org.opensearch.common.settings.Settings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.settings.Settings; import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.filter.SecurityRequestChannel; 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 334073118a..5b93f96f2e 100644 --- a/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java +++ b/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java @@ -19,12 +19,12 @@ import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; 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 98443a2902..3b3eeac1d6 100644 --- a/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java +++ b/src/main/java/org/opensearch/security/auth/internal/InternalAuthenticationBackend.java @@ -36,8 +36,6 @@ import java.util.Map.Entry; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; -import org.greenrobot.eventbus.Subscribe; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.security.auth.AuthenticationBackend; import org.opensearch.security.auth.AuthorizationBackend; @@ -45,6 +43,8 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +import org.greenrobot.eventbus.Subscribe; + public class InternalAuthenticationBackend implements AuthenticationBackend, AuthorizationBackend { private InternalUsersModel internalUsersModel; diff --git a/src/main/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtil.java b/src/main/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtil.java index 2e11fed64a..4cd2ddab2a 100644 --- a/src/main/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtil.java +++ b/src/main/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtil.java @@ -14,7 +14,6 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Base64; - import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; diff --git a/src/main/java/org/opensearch/security/authtoken/jwt/JwtVendor.java b/src/main/java/org/opensearch/security/authtoken/jwt/JwtVendor.java index 6340688607..57dcd15da6 100644 --- a/src/main/java/org/opensearch/security/authtoken/jwt/JwtVendor.java +++ b/src/main/java/org/opensearch/security/authtoken/jwt/JwtVendor.java @@ -18,10 +18,13 @@ import java.util.Optional; import java.util.function.LongSupplier; -import com.nimbusds.jose.JOSEException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.OpenSearchException; +import org.opensearch.common.collect.Tuple; +import org.opensearch.common.settings.Settings; +import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSHeader; import com.nimbusds.jose.JWSSigner; @@ -33,10 +36,6 @@ import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; -import org.opensearch.OpenSearchException; -import org.opensearch.common.collect.Tuple; -import org.opensearch.common.settings.Settings; - import static org.opensearch.security.util.AuthTokenUtils.isKeyNull; public class JwtVendor { diff --git a/src/main/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtil.java b/src/main/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtil.java index 41bf2955f2..7c041a5c2f 100644 --- a/src/main/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtil.java +++ b/src/main/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtil.java @@ -11,10 +11,11 @@ package org.opensearch.security.authtoken.jwt; +import org.apache.commons.lang3.StringUtils; + import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.util.ByteUtils; -import org.apache.commons.lang3.StringUtils; import static com.nimbusds.jose.crypto.MACSigner.getMinRequiredSecretLength; diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java index 1d81479f37..994ae5963f 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java @@ -40,6 +40,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.annotations.VisibleForTesting; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -47,13 +49,6 @@ 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.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.settings.Settings; import org.opensearch.core.common.Strings; import org.opensearch.security.DefaultObjectMapper; @@ -61,6 +56,11 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + 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 c1ac1271bb..9e02f8b45c 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java @@ -15,8 +15,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.OpenSearchException; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.IndexService; import org.opensearch.index.engine.Engine.Delete; import org.opensearch.index.engine.Engine.DeleteResult; @@ -24,7 +24,6 @@ import org.opensearch.index.engine.Engine.IndexResult; import org.opensearch.index.get.GetResult; import org.opensearch.index.shard.IndexShard; -import org.opensearch.core.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 3f2d764f1d..1b3e21288a 100644 --- a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java +++ b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java @@ -19,24 +19,24 @@ import java.util.Objects; import java.util.function.Function; -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; import org.opensearch.core.index.Index; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.Uid; -import org.opensearch.core.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 //Check if we can hook in into the caches diff --git a/src/main/java/org/opensearch/security/configuration/AdminDNs.java b/src/main/java/org/opensearch/security/configuration/AdminDNs.java index 204f277808..2eb27e8bb6 100644 --- a/src/main/java/org/opensearch/security/configuration/AdminDNs.java +++ b/src/main/java/org/opensearch/security/configuration/AdminDNs.java @@ -33,14 +33,12 @@ import java.util.Objects; import java.util.Set; import java.util.function.Function; - import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import com.google.common.collect.ImmutableMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; diff --git a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java index d7429c5d1d..a0428f39d0 100644 --- a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java +++ b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java @@ -28,7 +28,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateListener; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/src/main/java/org/opensearch/security/configuration/CompatConfig.java b/src/main/java/org/opensearch/security/configuration/CompatConfig.java index ec2a521afe..90d86cdcfa 100644 --- a/src/main/java/org/opensearch/security/configuration/CompatConfig.java +++ b/src/main/java/org/opensearch/security/configuration/CompatConfig.java @@ -28,14 +28,14 @@ import org.apache.logging.log4j.LogManager; 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 org.greenrobot.eventbus.Subscribe; + import static org.opensearch.security.support.ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY; public class CompatConfig { diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java index ac53895310..ec06d75ec6 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java @@ -39,8 +39,6 @@ import com.fasterxml.jackson.databind.JsonNode; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - -import org.opensearch.core.action.ActionListener; import org.opensearch.action.get.GetResponse; import org.opensearch.action.get.MultiGetItemResponse; import org.opensearch.action.get.MultiGetRequest; @@ -48,10 +46,11 @@ import org.opensearch.action.get.MultiGetResponse.Failure; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.security.DefaultObjectMapper; diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java index 04ad8f7420..606fbbd610 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java @@ -42,12 +42,11 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.ResourceAlreadyExistsException; @@ -63,9 +62,9 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; import org.opensearch.core.common.Strings; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.Environment; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.securityconf.DynamicConfigFactory; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java b/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java index 099e27c238..4fe98068ff 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFilterLevelActionHandler.java @@ -23,7 +23,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java index 84dc7f8c19..8ba293bbab 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsFilterLeafReader.java @@ -27,9 +27,6 @@ import java.util.Set; import java.util.function.Function; -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; @@ -62,20 +59,22 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.automaton.CompiledAutomaton; - +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterators; import org.opensearch.ExceptionsHelper; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.lucene.index.SequentialStoredFieldsLeafReader; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.IndexService; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.compliance.FieldReadCallback; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsRequestValve.java b/src/main/java/org/opensearch/security/configuration/DlsFlsRequestValve.java index 954461b43d..1152799bd5 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsRequestValve.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsRequestValve.java @@ -26,8 +26,8 @@ package org.opensearch.security.configuration; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.search.internal.SearchContext; import org.opensearch.search.query.QuerySearchResult; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java index 06c94c26b5..80823fdecc 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java @@ -23,18 +23,16 @@ 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 com.google.common.collect.ImmutableList; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.RealtimeRequest; @@ -50,11 +48,12 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.Strings; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.index.query.ParsedQuery; -import org.opensearch.core.rest.RestStatus; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.AggregationBuilder; import org.opensearch.search.aggregations.AggregatorFactories; diff --git a/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java b/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java index 9640abcd8e..d3be264af5 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java +++ b/src/main/java/org/opensearch/security/configuration/DlsQueryParser.java @@ -17,8 +17,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; -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; @@ -29,7 +27,8 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.join.BitSetProducer; import org.apache.lucene.search.join.ToChildBlockJoinQuery; - +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.NamedXContentRegistry; diff --git a/src/main/java/org/opensearch/security/configuration/MaskedField.java b/src/main/java/org/opensearch/security/configuration/MaskedField.java index 8cb20ccdfe..e58bcaaf7b 100644 --- a/src/main/java/org/opensearch/security/configuration/MaskedField.java +++ b/src/main/java/org/opensearch/security/configuration/MaskedField.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.Objects; -import com.google.common.base.Splitter; import org.apache.lucene.util.BytesRef; +import com.google.common.base.Splitter; import org.bouncycastle.crypto.digests.Blake2bDigest; import org.bouncycastle.util.encoders.Hex; diff --git a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java index e4d75c5611..2f04b75f8d 100644 --- a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java +++ b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java @@ -14,11 +14,10 @@ import java.util.Map; import java.util.Set; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.opensearch.OpenSearchException; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; diff --git a/src/main/java/org/opensearch/security/configuration/Salt.java b/src/main/java/org/opensearch/security/configuration/Salt.java index 3799fa846f..f5c0a5414d 100644 --- a/src/main/java/org/opensearch/security/configuration/Salt.java +++ b/src/main/java/org/opensearch/security/configuration/Salt.java @@ -15,10 +15,9 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import com.google.common.annotations.VisibleForTesting; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.annotations.VisibleForTesting; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; diff --git a/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java b/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java index b6df13c9d9..4e66cf7d05 100644 --- a/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java +++ b/src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java @@ -17,17 +17,16 @@ import java.util.Set; import java.util.function.LongSupplier; -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 com.google.common.collect.Sets; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.IgnoredFieldMapper; import org.opensearch.index.query.QueryShardContext; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.shard.ShardUtils; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.compliance.ComplianceIndexingOperationListener; diff --git a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java index 15a20db98d..73966c8f40 100644 --- a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java +++ b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java @@ -32,12 +32,10 @@ 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.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.index.Index; import org.opensearch.index.IndexService; import org.opensearch.security.privileges.PrivilegesEvaluator; @@ -47,6 +45,8 @@ import org.opensearch.security.support.WildcardMatcher; import org.opensearch.security.user.User; +import org.greenrobot.eventbus.Subscribe; + public class SecurityIndexSearcherWrapper implements CheckedFunction { protected final Logger log = LogManager.getLogger(this.getClass()); 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 6cbd7eaf78..a08f3cd976 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 @@ -11,16 +11,21 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + import com.fasterxml.jackson.core.JsonPointer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.flipkart.zjsonpatch.JsonPatch; -import com.flipkart.zjsonpatch.JsonPatchApplicationException; -import com.google.common.collect.ImmutableSet; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableSet; import org.opensearch.ExceptionsHelper; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; @@ -57,12 +62,8 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import com.flipkart.zjsonpatch.JsonPatch; +import com.flipkart.zjsonpatch.JsonPatchApplicationException; import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; 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 e4a1c0d05a..67344b053c 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 @@ -11,10 +11,14 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.tuple.Triple; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import org.apache.commons.lang3.tuple.Triple; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -35,10 +39,6 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import java.util.List; -import java.util.Map; -import java.util.Set; - import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; import static org.opensearch.security.dlic.rest.api.Responses.ok; import static org.opensearch.security.dlic.rest.api.Responses.response; 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 5eb4f202bf..1b94169e46 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 @@ -11,6 +11,11 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -29,11 +34,6 @@ import org.opensearch.security.securityconf.impl.v7.ActionGroupsV7; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; - import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/AllowlistApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/AllowlistApiAction.java index 349247ee01..fa2ae1ca3a 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/AllowlistApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/AllowlistApiAction.java @@ -11,6 +11,9 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; +import java.util.Map; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.opensearch.cluster.service.ClusterService; @@ -25,9 +28,6 @@ import org.opensearch.security.tools.SecurityAdmin; import org.opensearch.threadpool.ThreadPool; -import java.util.List; -import java.util.Map; - import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; /** 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 20e424e959..e61b292541 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 @@ -11,6 +11,11 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.annotations.VisibleForTesting; @@ -32,11 +37,6 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; - import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; import static org.opensearch.security.dlic.rest.api.Responses.conflictMessage; import static org.opensearch.security.dlic.rest.api.Responses.methodNotImplementedMessage; 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 e124abb5f7..bc37f41d6e 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 @@ -11,15 +11,15 @@ package org.opensearch.security.dlic.rest.api; +import java.util.Collections; +import java.util.List; + import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.rest.RestRequest.Method; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.threadpool.ThreadPool; -import java.util.Collections; -import java.util.List; - import static org.opensearch.security.dlic.rest.api.Responses.ok; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; 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 640e52df6e..cc070ebf5d 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 @@ -11,9 +11,11 @@ package org.opensearch.security.dlic.rest.api; -import com.google.common.collect.ImmutableList; +import java.util.List; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; @@ -25,8 +27,6 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.threadpool.ThreadPool; -import java.util.List; - import static org.opensearch.security.dlic.rest.api.Responses.internalSeverError; import static org.opensearch.security.dlic.rest.api.Responses.ok; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; 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 449762c8ff..748f5a8936 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 @@ -11,6 +11,10 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; + import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -35,10 +39,6 @@ import org.opensearch.security.user.UserServiceException; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; - import static org.opensearch.security.dlic.rest.api.Responses.badRequest; import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; import static org.opensearch.security.dlic.rest.api.Responses.methodNotImplementedMessage; 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 7f72a92640..32431fcf5a 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 @@ -13,9 +13,13 @@ // CS-SUPPRESS-SINGLE: RegexpSingleline https://github.com/opensearch-project/OpenSearch/issues/3663 -import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.bulk.BulkRequestBuilder; import org.opensearch.action.bulk.BulkResponse; @@ -55,10 +59,6 @@ import org.opensearch.security.securityconf.impl.v7.TenantV7; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.Collections; -import java.util.List; - import static org.opensearch.security.dlic.rest.api.Responses.badRequest; import static org.opensearch.security.dlic.rest.api.Responses.internalSeverError; import static org.opensearch.security.dlic.rest.api.Responses.ok; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiAction.java index 9928c7897a..2a9378d532 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiAction.java @@ -11,12 +11,6 @@ package org.opensearch.security.dlic.rest.api; -import static org.opensearch.rest.RestRequest.Method.GET; -import static org.opensearch.rest.RestRequest.Method.PUT; -import static org.opensearch.security.dlic.rest.api.Responses.ok; -import static org.opensearch.security.dlic.rest.api.Responses.response; -import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; - import java.io.IOException; import java.util.List; import java.util.Map; @@ -25,6 +19,9 @@ import java.util.Set; 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.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -40,9 +37,11 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import static org.opensearch.rest.RestRequest.Method.GET; +import static org.opensearch.rest.RestRequest.Method.PUT; +import static org.opensearch.security.dlic.rest.api.Responses.ok; +import static org.opensearch.security.dlic.rest.api.Responses.response; +import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; public class MultiTenancyConfigApiAction extends AbstractApiAction { 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 ed1f3e0fbb..d977e75cbc 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 @@ -18,7 +18,6 @@ import java.util.Set; import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.opensearch.cluster.service.ClusterService; 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 56d2d24337..05a220b411 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 @@ -20,12 +20,12 @@ 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; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.transport.TransportAddress; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; @@ -33,7 +33,6 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/RequestHandler.java b/src/main/java/org/opensearch/security/dlic/rest/api/RequestHandler.java index d9b26c262b..9ab073ace4 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RequestHandler.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RequestHandler.java @@ -11,6 +11,14 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Predicate; + import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.common.CheckedFunction; @@ -20,14 +28,6 @@ import org.opensearch.security.dlic.rest.validation.ValidationResult; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Consumer; -import java.util.function.Predicate; - import static org.opensearch.security.dlic.rest.api.Responses.created; import static org.opensearch.security.dlic.rest.api.Responses.forbidden; import static org.opensearch.security.dlic.rest.api.Responses.methodNotImplemented; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/Responses.java b/src/main/java/org/opensearch/security/dlic/rest/api/Responses.java index 6af8f0e936..4f895d1a91 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/Responses.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/Responses.java @@ -11,6 +11,8 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; + import org.opensearch.ExceptionsHelper; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.ToXContent; @@ -18,8 +20,6 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; -import java.io.IOException; - public class Responses { public static void ok(final RestChannel channel, final String message) { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/RestApiAdminPrivilegesEvaluator.java b/src/main/java/org/opensearch/security/dlic/rest/api/RestApiAdminPrivilegesEvaluator.java index a63c496e38..c717459d9e 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RestApiAdminPrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RestApiAdminPrivilegesEvaluator.java @@ -14,13 +14,12 @@ import java.util.Locale; import java.util.Map; -import com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - -import org.opensearch.core.common.transport.TransportAddress; +import com.google.common.collect.ImmutableMap; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.privileges.PrivilegesEvaluator; 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 f1a336986b..1f72bc3909 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 @@ -28,7 +28,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.Settings; import org.opensearch.core.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 76ff702455..35e32f562e 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 @@ -11,11 +11,17 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.StreamSupport; + import com.fasterxml.jackson.core.JsonPointer; import com.fasterxml.jackson.databind.JsonNode; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.commons.lang3.tuple.Pair; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.settings.Settings; @@ -31,12 +37,6 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.StreamSupport; - import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; 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 15fef92a5f..e5125f4fe9 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 @@ -17,7 +17,6 @@ import java.util.Set; import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.opensearch.cluster.service.ClusterService; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiAction.java index f71135ce50..d28ef7052e 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiAction.java @@ -11,6 +11,9 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; +import java.util.Map; + import com.google.common.collect.ImmutableMap; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; @@ -24,9 +27,6 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import java.util.List; -import java.util.Map; - import static org.opensearch.security.dlic.rest.api.RequestHandler.methodNotImplementedHandler; import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.SECURITY_CONFIG_UPDATE; import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfiguration.java b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfiguration.java index 68f17ac5f5..02e4f96554 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfiguration.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfiguration.java @@ -11,12 +11,12 @@ package org.opensearch.security.dlic.rest.api; -import com.fasterxml.jackson.databind.JsonNode; -import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; - import java.util.Objects; import java.util.Optional; +import com.fasterxml.jackson.databind.JsonNode; +import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; + public class SecurityConfiguration { private final String entityName; diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityRestApiActions.java b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityRestApiActions.java index 78f9ce91df..b0d46f8774 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/SecurityRestApiActions.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/SecurityRestApiActions.java @@ -11,6 +11,10 @@ package org.opensearch.security.dlic.rest.api; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; + import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -25,10 +29,6 @@ import org.opensearch.security.user.UserService; import org.opensearch.threadpool.ThreadPool; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; - import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; public class SecurityRestApiActions { diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiAction.java index 1dee3d8c84..86feec18a0 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiAction.java @@ -11,6 +11,13 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.opensearch.OpenSearchSecurityException; @@ -26,13 +33,6 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.opensearch.security.dlic.rest.api.Responses.badRequest; import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; import static org.opensearch.security.dlic.rest.api.Responses.ok; 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 ee716f70b5..38040ff89c 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 @@ -31,7 +31,6 @@ import java.util.Map; import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableMap; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; 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 8f764e94c3..93f1cd35c3 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 @@ -11,6 +11,10 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.collect.Tuple; import org.opensearch.common.inject.Inject; @@ -35,10 +39,6 @@ import org.opensearch.security.securityconf.impl.v7.TenantV7; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.Collections; -import java.util.List; - import static org.opensearch.security.dlic.rest.api.Responses.badRequest; import static org.opensearch.security.dlic.rest.api.Responses.internalSeverError; import static org.opensearch.security.dlic.rest.api.Responses.ok; 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 2545bb2e23..658e3d15f8 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 @@ -15,7 +15,6 @@ import java.util.List; import com.google.common.collect.ImmutableList; - import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.rest.RestRequest; 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 3853ee5f46..ee6bc9c765 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 @@ -28,21 +28,20 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import org.apache.commons.lang3.tuple.Pair; import org.bouncycastle.crypto.generators.OpenBSDBCrypt; - import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchParseException; import org.opensearch.SpecialPermission; import org.opensearch.common.CheckedSupplier; -import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/EndpointValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/EndpointValidator.java index e4b08b8c3f..5879272b30 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/EndpointValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/EndpointValidator.java @@ -9,6 +9,10 @@ */ package org.opensearch.security.dlic.rest.validation; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + import org.opensearch.core.rest.RestStatus; import org.opensearch.security.dlic.rest.api.Endpoint; import org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator; @@ -16,10 +20,6 @@ import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import java.io.IOException; -import java.util.List; -import java.util.Objects; - import static org.opensearch.security.dlic.rest.api.Responses.badRequestMessage; import static org.opensearch.security.dlic.rest.api.Responses.forbiddenMessage; import static org.opensearch.security.dlic.rest.api.Responses.notFoundMessage; diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/PasswordValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/PasswordValidator.java index d45be33e6a..dfc1b58aab 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/PasswordValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/PasswordValidator.java @@ -11,15 +11,6 @@ package org.opensearch.security.dlic.rest.validation; -import com.google.common.collect.ImmutableList; -import com.nulabinc.zxcvbn.Strength; -import com.nulabinc.zxcvbn.Zxcvbn; -import com.nulabinc.zxcvbn.matchers.Match; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.Strings; - import java.util.List; import java.util.Locale; import java.util.Objects; @@ -27,6 +18,16 @@ import java.util.function.Predicate; import java.util.regex.Pattern; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; +import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.Strings; + +import com.nulabinc.zxcvbn.Strength; +import com.nulabinc.zxcvbn.Zxcvbn; +import com.nulabinc.zxcvbn.matchers.Match; + import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_MIN_LENGTH; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_SCORE_BASED_VALIDATION_STRENGTH; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_VALIDATION_REGEX; diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/RequestContentValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/RequestContentValidator.java index 5889bf5504..dac1361f5f 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/RequestContentValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/RequestContentValidator.java @@ -11,6 +11,14 @@ package org.opensearch.security.dlic.rest.validation; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.JsonNode; @@ -24,14 +32,6 @@ import org.opensearch.rest.RestRequest; import org.opensearch.security.DefaultObjectMapper; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_VALIDATION_ERROR_MESSAGE; public class RequestContentValidator implements ToXContent { diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/ValidationResult.java b/src/main/java/org/opensearch/security/dlic/rest/validation/ValidationResult.java index 7fb91d8913..ea782ea504 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/ValidationResult.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/ValidationResult.java @@ -11,14 +11,14 @@ package org.opensearch.security.dlic.rest.validation; +import java.io.IOException; +import java.util.Objects; + import org.opensearch.common.CheckedBiConsumer; import org.opensearch.common.CheckedConsumer; import org.opensearch.common.CheckedFunction; -import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.rest.RestStatus; - -import java.io.IOException; -import java.util.Objects; +import org.opensearch.core.xcontent.ToXContent; public class ValidationResult { diff --git a/src/main/java/org/opensearch/security/filter/DelegatingRestHandler.java b/src/main/java/org/opensearch/security/filter/DelegatingRestHandler.java index 3ad111c6fb..8e9a9f5037 100644 --- a/src/main/java/org/opensearch/security/filter/DelegatingRestHandler.java +++ b/src/main/java/org/opensearch/security/filter/DelegatingRestHandler.java @@ -8,14 +8,14 @@ package org.opensearch.security.filter; +import java.util.List; +import java.util.Objects; + import org.opensearch.client.node.NodeClient; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestHandler; import org.opensearch.rest.RestRequest; -import java.util.List; -import java.util.Objects; - /** * Delegating RestHandler that delegates all implementations to original handler * diff --git a/src/main/java/org/opensearch/security/filter/NettyRequest.java b/src/main/java/org/opensearch/security/filter/NettyRequest.java index f3f2827367..7b65e4e0de 100644 --- a/src/main/java/org/opensearch/security/filter/NettyRequest.java +++ b/src/main/java/org/opensearch/security/filter/NettyRequest.java @@ -18,15 +18,14 @@ import java.util.Map; import java.util.Optional; import java.util.TreeMap; - import javax.net.ssl.SSLEngine; -import io.netty.handler.ssl.SslHandler; import org.opensearch.http.netty4.Netty4HttpChannel; import org.opensearch.rest.RestRequest.Method; +import org.opensearch.rest.RestUtils; import io.netty.handler.codec.http.HttpRequest; -import org.opensearch.rest.RestUtils; +import io.netty.handler.ssl.SslHandler; /** * Wraps the functionality of HttpRequest for use in the security plugin diff --git a/src/main/java/org/opensearch/security/filter/NettyRequestChannel.java b/src/main/java/org/opensearch/security/filter/NettyRequestChannel.java index a83ecdea8a..7afddbb618 100644 --- a/src/main/java/org/opensearch/security/filter/NettyRequestChannel.java +++ b/src/main/java/org/opensearch/security/filter/NettyRequestChannel.java @@ -15,11 +15,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import io.netty.handler.codec.http.HttpRequest; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.http.netty4.Netty4HttpChannel; +import io.netty.handler.codec.http.HttpRequest; + public class NettyRequestChannel extends NettyRequest implements SecurityRequestChannel { private final Logger log = LogManager.getLogger(NettyRequestChannel.class); diff --git a/src/main/java/org/opensearch/security/filter/OpenSearchRequest.java b/src/main/java/org/opensearch/security/filter/OpenSearchRequest.java index 85c70b8f7a..80ede8b2c1 100644 --- a/src/main/java/org/opensearch/security/filter/OpenSearchRequest.java +++ b/src/main/java/org/opensearch/security/filter/OpenSearchRequest.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; - import javax.net.ssl.SSLEngine; import org.opensearch.http.netty4.Netty4HttpChannel; diff --git a/src/main/java/org/opensearch/security/filter/SecurityFilter.java b/src/main/java/org/opensearch/security/filter/SecurityFilter.java index 00b117ebb8..de4e19fdc7 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityFilter.java @@ -31,18 +31,15 @@ import java.util.UUID; import java.util.stream.Collectors; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableSet; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.ResourceAlreadyExistsException; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.core.action.ActionResponse; import org.opensearch.action.DocWriteRequest.OpType; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.action.admin.indices.alias.Alias; @@ -68,10 +65,12 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.concurrent.ThreadContext.StoredContext; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.logging.LoggerMessageFormat; +import org.opensearch.core.rest.RestStatus; import org.opensearch.index.reindex.DeleteByQueryRequest; import org.opensearch.index.reindex.UpdateByQueryRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.action.whoami.WhoAmIAction; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; diff --git a/src/main/java/org/opensearch/security/filter/SecurityRequest.java b/src/main/java/org/opensearch/security/filter/SecurityRequest.java index ab6f41b354..4c7ea27a87 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRequest.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRequest.java @@ -16,7 +16,6 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Stream; - import javax.net.ssl.SSLEngine; import org.opensearch.rest.RestRequest.Method; diff --git a/src/main/java/org/opensearch/security/filter/SecurityRequestFactory.java b/src/main/java/org/opensearch/security/filter/SecurityRequestFactory.java index 0b64d0220d..31fe78b87d 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRequestFactory.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRequestFactory.java @@ -11,11 +11,12 @@ package org.opensearch.security.filter; -import io.netty.handler.codec.http.HttpRequest; import org.opensearch.http.netty4.Netty4HttpChannel; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; +import io.netty.handler.codec.http.HttpRequest; + /** * Generates wrapped versions of requests for use in the security plugin */ diff --git a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java index c492656bca..dc134f00cf 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java @@ -31,14 +31,11 @@ import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; - import javax.net.ssl.SSLPeerUnverifiedException; import org.apache.http.HttpStatus; 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; @@ -67,6 +64,8 @@ import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; +import org.greenrobot.eventbus.Subscribe; + import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; import static org.opensearch.security.http.SecurityHttpServerTransport.CONTEXT_TO_RESTORE; diff --git a/src/main/java/org/opensearch/security/filter/SecurityRestUtils.java b/src/main/java/org/opensearch/security/filter/SecurityRestUtils.java index 705fe31ee0..0fd112b444 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRestUtils.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRestUtils.java @@ -11,14 +11,14 @@ package org.opensearch.security.filter; -import static org.opensearch.security.filter.SecurityRestFilter.HEALTH_SUFFIX; -import static org.opensearch.security.filter.SecurityRestFilter.PATTERN_PATH_PREFIX; -import static org.opensearch.security.filter.SecurityRestFilter.WHO_AM_I_SUFFIX; - import java.util.regex.Matcher; import org.opensearch.rest.RestRequest.Method; +import static org.opensearch.security.filter.SecurityRestFilter.HEALTH_SUFFIX; +import static org.opensearch.security.filter.SecurityRestFilter.PATTERN_PATH_PREFIX; +import static org.opensearch.security.filter.SecurityRestFilter.WHO_AM_I_SUFFIX; + public class SecurityRestUtils { public static String path(final String uri) { final int index = uri.indexOf('?'); diff --git a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java index ff07db147e..bc7546062f 100644 --- a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java @@ -33,7 +33,6 @@ import org.apache.http.HttpStatus; 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.security.auth.HTTPAuthenticator; diff --git a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java index 433ec01458..50b502b3b6 100644 --- a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java @@ -31,14 +31,12 @@ import java.util.Collections; import java.util.List; import java.util.Optional; - import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; 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.core.common.Strings; diff --git a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java index e49248a0dc..d20e7554ce 100644 --- a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java @@ -32,7 +32,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; diff --git a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java index f493b7c919..6e5980ab64 100644 --- a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java @@ -11,10 +11,6 @@ package org.opensearch.security.http; -import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; -import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; -import static org.opensearch.security.util.AuthTokenUtils.isAccessToRestrictedEndpoints; - import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; @@ -47,6 +43,10 @@ import io.jsonwebtoken.JwtParserBuilder; import io.jsonwebtoken.security.WeakKeyException; +import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX; +import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; +import static org.opensearch.security.util.AuthTokenUtils.isAccessToRestrictedEndpoints; + public class OnBehalfOfAuthenticator implements HTTPAuthenticator { private static final int MINIMUM_SIGNING_KEY_BIT_LENGTH = 512; diff --git a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java index 7b76a82c42..1890296889 100644 --- a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java +++ b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java @@ -51,7 +51,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.security.filter.SecurityRequest; import org.opensearch.security.support.ConfigConstants; diff --git a/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java b/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java index 3b70a5ebda..c5fbbfbbc6 100644 --- a/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/http/SecurityHttpServerTransport.java @@ -26,7 +26,6 @@ package org.opensearch.security.http; -import io.netty.util.AttributeKey; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -43,6 +42,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; +import io.netty.util.AttributeKey; + public class SecurityHttpServerTransport extends SecuritySSLNettyHttpServerTransport { public static final AttributeKey EARLY_RESPONSE = AttributeKey.newInstance("opensearch-http-early-response"); diff --git a/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java b/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java index cca1df9b46..f37ebb48e8 100644 --- a/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/http/SecurityNonSslHttpServerTransport.java @@ -26,10 +26,6 @@ package org.opensearch.security.http; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; - -import io.netty.channel.ChannelInboundHandlerAdapter; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -44,6 +40,10 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelInboundHandlerAdapter; + public class SecurityNonSslHttpServerTransport extends Netty4HttpServerTransport { private final ChannelInboundHandlerAdapter headerVerifier; diff --git a/src/main/java/org/opensearch/security/http/XFFResolver.java b/src/main/java/org/opensearch/security/http/XFFResolver.java index 7fcbfad888..4e9df7db5e 100644 --- a/src/main/java/org/opensearch/security/http/XFFResolver.java +++ b/src/main/java/org/opensearch/security/http/XFFResolver.java @@ -30,16 +30,16 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.greenrobot.eventbus.Subscribe; - import org.opensearch.OpenSearchSecurityException; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.security.filter.SecurityRequest; 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 { protected final Logger log = LogManager.getLogger(this.getClass()); 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 9a16e6c61b..6d46bfa9aa 100644 --- a/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java @@ -30,10 +30,9 @@ import java.util.List; import java.util.Map.Entry; -import com.google.common.base.Joiner; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.base.Joiner; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.common.Strings; diff --git a/src/main/java/org/opensearch/security/httpclient/HttpClient.java b/src/main/java/org/opensearch/security/httpclient/HttpClient.java index ba788a2c13..85e280e2f4 100644 --- a/src/main/java/org/opensearch/security/httpclient/HttpClient.java +++ b/src/main/java/org/opensearch/security/httpclient/HttpClient.java @@ -26,13 +26,11 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; -import com.google.common.collect.Lists; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder; import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder; @@ -52,7 +50,7 @@ import org.apache.hc.core5.ssl.SSLContexts; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.Lists; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.support.WriteRequest.RefreshPolicy; diff --git a/src/main/java/org/opensearch/security/identity/SecurityTokenManager.java b/src/main/java/org/opensearch/security/identity/SecurityTokenManager.java index 9f4ffecf57..a02b18977e 100644 --- a/src/main/java/org/opensearch/security/identity/SecurityTokenManager.java +++ b/src/main/java/org/opensearch/security/identity/SecurityTokenManager.java @@ -15,10 +15,8 @@ import java.util.Set; import java.util.stream.Collectors; -import joptsimple.internal.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.greenrobot.eventbus.Subscribe; import org.opensearch.OpenSearchSecurityException; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -37,6 +35,9 @@ import org.opensearch.security.user.UserService; import org.opensearch.threadpool.ThreadPool; +import joptsimple.internal.Strings; +import org.greenrobot.eventbus.Subscribe; + /** * This class is the Security Plugin's implementation of the TokenManager used by all Identity Plugins. * It handles the issuance of both Service Account Tokens and On Behalf Of tokens. diff --git a/src/main/java/org/opensearch/security/opensaml/integration/CleanerFactory.java b/src/main/java/org/opensearch/security/opensaml/integration/CleanerFactory.java index 7b0d968c57..7b6d1575f7 100644 --- a/src/main/java/org/opensearch/security/opensaml/integration/CleanerFactory.java +++ b/src/main/java/org/opensearch/security/opensaml/integration/CleanerFactory.java @@ -11,13 +11,14 @@ package org.opensearch.security.opensaml.integration; +import java.lang.ref.Cleaner; +import java.util.concurrent.ThreadFactory; + import org.opensearch.common.util.concurrent.OpenSearchExecutors; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.ref.Cleaner; -import java.util.concurrent.ThreadFactory; - /** * The class was adapted from {@link net.shibboleth.utilities.java.support.primitive.CleanerSupport}. * The main reason is that it is only one way to set Cleaner.create() diff --git a/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CRLImpl.java b/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CRLImpl.java index 716826e742..036b777e27 100644 --- a/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CRLImpl.java +++ b/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CRLImpl.java @@ -11,16 +11,16 @@ package org.opensearch.security.opensaml.integration; -import net.shibboleth.utilities.java.support.collection.IndexingObjectStore; -import org.opensaml.core.xml.AbstractXMLObject; -import org.opensaml.core.xml.XMLObject; -import org.opensaml.xmlsec.signature.X509CRL; - -import javax.annotation.Nonnull; import java.lang.ref.Cleaner; import java.util.Collections; import java.util.List; import java.util.Objects; +import javax.annotation.Nonnull; + +import net.shibboleth.utilities.java.support.collection.IndexingObjectStore; +import org.opensaml.core.xml.AbstractXMLObject; +import org.opensaml.core.xml.XMLObject; +import org.opensaml.xmlsec.signature.X509CRL; /** * The class was adapted from {@link org.opensaml.xmlsec.signature.impl.X509CRLImpl}. diff --git a/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CertificateImpl.java b/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CertificateImpl.java index 32013ab727..59fbc021d8 100644 --- a/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CertificateImpl.java +++ b/src/main/java/org/opensearch/security/opensaml/integration/SecurityX509CertificateImpl.java @@ -11,16 +11,16 @@ package org.opensearch.security.opensaml.integration; -import net.shibboleth.utilities.java.support.collection.IndexingObjectStore; -import org.opensaml.core.xml.AbstractXMLObject; -import org.opensaml.core.xml.XMLObject; -import org.opensaml.xmlsec.signature.X509Certificate; - -import javax.annotation.Nonnull; import java.lang.ref.Cleaner; import java.util.Collections; import java.util.List; import java.util.Objects; +import javax.annotation.Nonnull; + +import net.shibboleth.utilities.java.support.collection.IndexingObjectStore; +import org.opensaml.core.xml.AbstractXMLObject; +import org.opensaml.core.xml.XMLObject; +import org.opensaml.xmlsec.signature.X509Certificate; /** * The class was adapted from {@link org.opensaml.xmlsec.signature.impl.X509CertificateBuilder}. diff --git a/src/main/java/org/opensearch/security/opensaml/integration/SecurityXMLObjectProviderInitializer.java b/src/main/java/org/opensearch/security/opensaml/integration/SecurityXMLObjectProviderInitializer.java index bf87514bff..6cf6d0e6aa 100644 --- a/src/main/java/org/opensearch/security/opensaml/integration/SecurityXMLObjectProviderInitializer.java +++ b/src/main/java/org/opensearch/security/opensaml/integration/SecurityXMLObjectProviderInitializer.java @@ -11,9 +11,13 @@ package org.opensearch.security.opensaml.integration; -import net.shibboleth.utilities.java.support.primitive.StringSupport; +import java.io.IOException; +import java.io.InputStream; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; + +import net.shibboleth.utilities.java.support.primitive.StringSupport; import org.opensaml.core.config.InitializationException; import org.opensaml.core.xml.config.XMLConfigurationException; import org.opensaml.core.xml.config.XMLConfigurator; @@ -22,9 +26,6 @@ import org.opensaml.xmlsec.signature.impl.X509CertificateBuilder; import org.w3c.dom.Element; -import java.io.IOException; -import java.io.InputStream; - /** * The class extends {@link org.opensaml.xmlsec.config.impl.XMLObjectProviderInitializer} * which is responsible to map signature configuration from SAML diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index 538b541754..f1f94ea2a1 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -36,12 +36,10 @@ import java.util.Set; import java.util.StringJoiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.greenrobot.eventbus.Subscribe; - +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionRequest; import org.opensearch.action.IndicesRequest; @@ -77,9 +75,9 @@ import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.common.Strings; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.index.reindex.ReindexAction; import org.opensearch.security.auditlog.AuditLog; @@ -96,6 +94,8 @@ import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; +import org.greenrobot.eventbus.Subscribe; + 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/ProtectedIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java index e4fd404daa..1cc1e45c97 100644 --- a/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java @@ -16,7 +16,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluator.java index dc95e98d11..377c80c21f 100644 --- a/src/main/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluator.java @@ -15,18 +15,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.greenrobot.eventbus.Subscribe; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.security.securityconf.ConfigModel; import org.opensearch.security.securityconf.SecurityRoles; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; +import org.greenrobot.eventbus.Subscribe; + public class RestLayerPrivilegesEvaluator { protected final Logger log = LogManager.getLogger(this.getClass()); private final ClusterService clusterService; diff --git a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java index 4d5fb26050..14df249894 100644 --- a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java @@ -26,6 +26,12 @@ package org.opensearch.security.privileges; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.action.ActionRequest; @@ -43,12 +49,6 @@ import org.opensearch.security.user.User; import org.opensearch.tasks.Task; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - /** * This class performs authorization on requests targeting system indices * NOTE: diff --git a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java index 23612e1a52..59da33affa 100644 --- a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java @@ -30,7 +30,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java index d06a45726a..e5b02ee5c2 100644 --- a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java @@ -30,7 +30,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java index ea8985ee69..81059e9b53 100644 --- a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java +++ b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java @@ -40,11 +40,9 @@ import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.greenrobot.eventbus.Subscribe; - +import com.google.common.collect.ImmutableSet; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.IndicesRequest; @@ -95,6 +93,8 @@ import org.opensearch.transport.RemoteClusterService; import org.opensearch.transport.TransportRequest; +import org.greenrobot.eventbus.Subscribe; + import static org.opensearch.cluster.metadata.IndexAbstraction.Type.ALIAS; public class IndexResolverReplacer { diff --git a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java index 6a14541896..edcef13137 100644 --- a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java @@ -29,20 +29,19 @@ import java.io.IOException; import java.util.List; -import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +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.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; diff --git a/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java b/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java index bfbc16f98d..c189d5eb2c 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityConfigUpdateAction.java @@ -16,15 +16,14 @@ 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.core.rest.RestStatus; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.action.RestActions.NodesResponseRestListener; import org.opensearch.security.action.configupdate.ConfigUpdateAction; import org.opensearch.security.action.configupdate.ConfigUpdateRequest; diff --git a/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java b/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java index 579d42e7a6..6d6f7fa026 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityHealthAction.java @@ -30,16 +30,15 @@ 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.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.auth.BackendRegistry; import static org.opensearch.rest.RestRequest.Method.GET; diff --git a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java index a10c58f058..c0dac9967c 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java @@ -33,22 +33,21 @@ import java.util.List; import java.util.Set; -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 com.google.common.collect.ImmutableList; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.support.Base64Helper; import org.opensearch.security.support.ConfigConstants; diff --git a/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java b/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java index 4f560f40b6..c2330afab5 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityWhoAmIAction.java @@ -17,12 +17,12 @@ import java.util.List; import java.util.Set; -import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; @@ -30,7 +30,6 @@ import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.ssl.transport.PrincipalExtractor; diff --git a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java index f3afc0f006..8ed4454d2a 100644 --- a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java @@ -31,23 +31,22 @@ import java.util.List; import java.util.SortedMap; -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 com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.metadata.IndexAbstraction; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.ConfigurationRepository; import org.opensearch.security.privileges.PrivilegesEvaluator; diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java index 545d383ced..47ffde8eba 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java @@ -35,6 +35,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableSet; @@ -42,17 +44,14 @@ 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; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.set.Sets; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java index 0528590db9..07091b7a27 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java @@ -38,6 +38,9 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.util.Strings; import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableSet; @@ -45,18 +48,14 @@ 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.apache.logging.log4j.util.Strings; - import org.opensearch.ExceptionsHelper; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.set.Sets; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.security.resolver.IndexResolverReplacer.Resolved; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java index 7265699e7c..eb0d5f6d15 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java @@ -36,14 +36,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.collect.ImmutableList; -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.greenrobot.eventbus.Logger.JavaLogger; - +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; @@ -73,6 +69,10 @@ import org.opensearch.security.support.WildcardMatcher; import org.opensearch.threadpool.ThreadPool; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.EventBusBuilder; +import org.greenrobot.eventbus.Logger.JavaLogger; + public class DynamicConfigFactory implements Initializable, ConfigurationChangeListener { public static final EventBusBuilder EVENT_BUS_BUILDER = EventBus.builder(); diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java index e3d10878da..b219d0ea40 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java @@ -34,10 +34,9 @@ import java.util.Set; import java.util.SortedSet; -import com.google.common.collect.Multimap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.Multimap; import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.AuthDomain; import org.opensearch.security.auth.AuthFailureListener; diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java index e5308aa574..98c4c1163b 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV6.java @@ -43,7 +43,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java index 0de83f2e2e..9afcd70e61 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModelV7.java @@ -45,7 +45,6 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; - import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; 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 938ee23c1e..c0ba8332c9 100644 --- a/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java +++ b/src/main/java/org/opensearch/security/securityconf/impl/SecurityDynamicConfiguration.java @@ -39,7 +39,6 @@ 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.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; 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 45fced168c..fe0d48ef8c 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 @@ -30,7 +30,6 @@ 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 0c95e56bd1..f6d7eaeacd 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 @@ -38,7 +38,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; 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 0db727ad99..d3c8899719 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 @@ -32,7 +32,6 @@ 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 f78c2f4305..35d949b825 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 @@ -32,7 +32,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - import org.opensearch.security.securityconf.Hideable; import org.opensearch.security.securityconf.RoleMappings; 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 8bc8b46249..f20da64422 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 @@ -35,7 +35,6 @@ 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 9ec9c25e5d..0705ffb3c5 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 @@ -31,7 +31,6 @@ 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 faeb5d2432..9d7645ade6 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 @@ -39,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; 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 8f10df04a4..93b06a4dc1 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 @@ -33,7 +33,6 @@ 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 229cae0e6f..49ba8ff3bb 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 @@ -36,7 +36,6 @@ 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 8fe47dcbd7..4a21710d49 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 @@ -28,7 +28,6 @@ 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 7c84cf779d..83a03a3df8 100644 --- a/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java +++ b/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java @@ -13,7 +13,6 @@ 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/ssl/DefaultSecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java index a3d18fba61..54cae52e4c 100644 --- a/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java @@ -17,19 +17,6 @@ package org.opensearch.security.ssl; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_KEYSTORE_KEYPASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_KEYSTORE_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_PEMKEY_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_TRUSTSTORE_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_CLIENT_KEYSTORE_KEYPASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_CLIENT_PEMKEY_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_KEYPASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_PEMKEY_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_SERVER_KEYSTORE_KEYPASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_SERVER_PEMKEY_PASSWORD; -import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_TRUSTSTORE_PASSWORD; - import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -56,7 +43,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; - import javax.crypto.Cipher; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; @@ -65,6 +51,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1ObjectIdentifier; @@ -86,9 +74,6 @@ import org.opensearch.security.ssl.util.SSLConfigConstants; import org.opensearch.transport.NettyAllocator; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - import io.netty.handler.codec.http2.Http2SecurityUtil; import io.netty.handler.ssl.ApplicationProtocolConfig; import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol; @@ -103,6 +88,19 @@ import io.netty.handler.ssl.SupportedCipherSuiteFilter; import io.netty.util.internal.PlatformDependent; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_KEYSTORE_KEYPASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_KEYSTORE_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_PEMKEY_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_TRUSTSTORE_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_CLIENT_KEYSTORE_KEYPASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_CLIENT_PEMKEY_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_KEYPASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_PEMKEY_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_SERVER_KEYSTORE_KEYPASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_SERVER_PEMKEY_PASSWORD; +import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_TRUSTSTORE_PASSWORD; + public class DefaultSecurityKeyStore implements SecurityKeyStore { private static final String DEFAULT_STORE_TYPE = "JKS"; diff --git a/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java index 9ea0276912..25d0599c58 100644 --- a/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/ExternalSecurityKeyStore.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; - import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; diff --git a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java index 722e55370e..c2f59bbf08 100644 --- a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java +++ b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java @@ -31,11 +31,8 @@ import java.util.function.Supplier; 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; @@ -44,7 +41,6 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.Booleans; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.network.NetworkModule; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; @@ -56,6 +52,7 @@ import org.opensearch.common.util.BigArrays; import org.opensearch.common.util.PageCacheRecycler; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.indices.breaker.CircuitBreakerService; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; @@ -88,6 +85,9 @@ import org.opensearch.transport.TransportInterceptor; import org.opensearch.watcher.ResourceWatcherService; +import io.netty.handler.ssl.OpenSsl; +import io.netty.util.internal.PlatformDependent; + //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/SecureSSLSettings.java b/src/main/java/org/opensearch/security/ssl/SecureSSLSettings.java index 1581deba20..0f6494c145 100644 --- a/src/main/java/org/opensearch/security/ssl/SecureSSLSettings.java +++ b/src/main/java/org/opensearch/security/ssl/SecureSSLSettings.java @@ -22,11 +22,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.SecureSetting; -import org.opensearch.core.common.settings.SecureString; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.settings.SecureString; import static org.opensearch.security.ssl.util.SSLConfigConstants.DEFAULT_STORE_PASSWORD; diff --git a/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java index 835ac92a23..03b5df2100 100644 --- a/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/SecurityKeyStore.java @@ -18,7 +18,6 @@ package org.opensearch.security.ssl; import java.security.cert.X509Certificate; - import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; diff --git a/src/main/java/org/opensearch/security/ssl/http/netty/Netty4ConditionalDecompressor.java b/src/main/java/org/opensearch/security/ssl/http/netty/Netty4ConditionalDecompressor.java index 1eec49add0..f133d997f9 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/Netty4ConditionalDecompressor.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/Netty4ConditionalDecompressor.java @@ -8,14 +8,14 @@ package org.opensearch.security.ssl.http.netty; +import org.opensearch.security.filter.NettyAttribute; + import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http.HttpContentDecompressor; import static org.opensearch.security.http.SecurityHttpServerTransport.EARLY_RESPONSE; import static org.opensearch.security.http.SecurityHttpServerTransport.SHOULD_DECOMPRESS; -import org.opensearch.security.filter.NettyAttribute; - public class Netty4ConditionalDecompressor extends HttpContentDecompressor { @Override diff --git a/src/main/java/org/opensearch/security/ssl/http/netty/Netty4HttpRequestHeaderVerifier.java b/src/main/java/org/opensearch/security/ssl/http/netty/Netty4HttpRequestHeaderVerifier.java index 51825e977b..9adca0f377 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/Netty4HttpRequestHeaderVerifier.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/Netty4HttpRequestHeaderVerifier.java @@ -8,15 +8,10 @@ package org.opensearch.security.ssl.http.netty; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.DefaultHttpRequest; -import io.netty.handler.codec.http.HttpRequest; -import io.netty.util.ReferenceCountUtil; import org.opensearch.ExceptionsHelper; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; - -import io.netty.channel.ChannelHandler.Sharable; -import io.netty.channel.ChannelHandlerContext; import org.opensearch.http.netty4.Netty4HttpChannel; import org.opensearch.http.netty4.Netty4HttpServerTransport; import org.opensearch.security.filter.SecurityRequestChannel; @@ -25,17 +20,22 @@ import org.opensearch.security.filter.SecurityResponse; import org.opensearch.security.filter.SecurityRestFilter; import org.opensearch.security.filter.SecurityRestUtils; +import org.opensearch.security.ssl.OpenSearchSecuritySSLPlugin; import org.opensearch.security.ssl.transport.SSLConfig; -import org.opensearch.threadpool.ThreadPool; import org.opensearch.security.support.ConfigConstants; -import org.opensearch.security.ssl.OpenSearchSecuritySSLPlugin; -import org.opensearch.common.settings.Settings; -import org.opensearch.OpenSearchSecurityException; +import org.opensearch.threadpool.ThreadPool; + +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.DefaultHttpRequest; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.util.ReferenceCountUtil; import static org.opensearch.security.http.SecurityHttpServerTransport.CONTEXT_TO_RESTORE; import static org.opensearch.security.http.SecurityHttpServerTransport.EARLY_RESPONSE; -import static org.opensearch.security.http.SecurityHttpServerTransport.SHOULD_DECOMPRESS; import static org.opensearch.security.http.SecurityHttpServerTransport.IS_AUTHENTICATED; +import static org.opensearch.security.http.SecurityHttpServerTransport.SHOULD_DECOMPRESS; @Sharable public class Netty4HttpRequestHeaderVerifier extends SimpleChannelInboundHandler { 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 eb2acdce49..c68ac1fed6 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,17 +17,8 @@ package org.opensearch.security.ssl.http.netty; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.ssl.ApplicationProtocolNames; -import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler; -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; @@ -44,6 +35,15 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.SharedGroupFactory; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.DecoderException; +import io.netty.handler.ssl.ApplicationProtocolNames; +import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler; +import io.netty.handler.ssl.SslHandler; + public class SecuritySSLNettyHttpServerTransport extends Netty4HttpServerTransport { private static final Logger logger = LogManager.getLogger(SecuritySSLNettyHttpServerTransport.class); private final SecurityKeyStore sks; 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 dcd25c2837..fc240bf4d8 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 @@ -18,21 +18,19 @@ package org.opensearch.security.ssl.http.netty; import java.nio.file.Path; - import javax.net.ssl.SSLPeerUnverifiedException; 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.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.rest.RestStatus; import org.opensearch.http.HttpServerTransport.Dispatcher; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.filter.SecurityRequestChannel; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.ssl.SslExceptionHandler; 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 8e32893eab..4f9faffd4d 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java @@ -25,12 +25,11 @@ import java.util.List; import java.util.stream.Collectors; -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.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; @@ -38,13 +37,14 @@ import org.opensearch.rest.RestController; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.ssl.SecurityKeyStore; import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.security.ssl.util.SSLRequestHelper; import org.opensearch.security.ssl.util.SSLRequestHelper.SSLInfo; +import io.netty.handler.ssl.OpenSsl; + public class SecuritySSLInfoAction extends BaseRestHandler { private static final List routes = Collections.singletonList(new Route(Method.GET, "/_opendistro/_security/sslinfo")); 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 8878a2b0f5..c580e3e37e 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; - import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; @@ -32,7 +31,6 @@ 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 5e85638dd1..bfc05b38c8 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java @@ -12,10 +12,15 @@ import java.nio.charset.StandardCharsets; import java.util.List; - import javax.net.ssl.SSLException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.annotations.VisibleForTesting; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.ssl.util.SSLConnectionTestUtil; +import org.opensearch.security.ssl.util.TLSUtil; + import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; @@ -23,12 +28,6 @@ import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.ssl.SslHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -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 d30e45022a..597b387936 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java @@ -13,7 +13,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; 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 7aeebdaf9f..e9f0764c09 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java @@ -32,27 +32,18 @@ import java.net.SocketAddress; import java.security.AccessController; import java.security.PrivilegedAction; - import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; -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; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.PageCacheRecycler; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.indices.breaker.CircuitBreakerService; import org.opensearch.security.ssl.SecurityKeyStore; import org.opensearch.security.ssl.SslExceptionHandler; @@ -65,6 +56,14 @@ import org.opensearch.transport.TcpChannel; import org.opensearch.transport.netty4.Netty4Transport; +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 63148d4ce6..3779a19667 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java @@ -21,13 +21,10 @@ import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Arrays; - import javax.net.ssl.SSLPeerUnverifiedException; -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.OpenSearchException; import org.opensearch.common.util.concurrent.ThreadContext; @@ -45,6 +42,8 @@ import org.opensearch.transport.TransportRequestHandler; import org.opensearch.transport.netty4.Netty4TcpChannel; +import io.netty.handler.ssl.SslHandler; + public class SecuritySSLRequestHandler implements TransportRequestHandler { private final String action; 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 e3143d969d..9f37e587ea 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java @@ -19,7 +19,6 @@ 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; 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 d543587090..44d5df17ea 100644 --- a/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java +++ b/src/main/java/org/opensearch/security/ssl/util/CertFromKeystore.java @@ -21,7 +21,6 @@ import java.security.cert.X509Certificate; import org.apache.commons.lang3.ArrayUtils; - import org.opensearch.OpenSearchException; public class CertFromKeystore { 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 640c3ef705..35917af586 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java @@ -33,7 +33,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.core.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 99465abffa..ba48caed28 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java @@ -19,9 +19,9 @@ import java.net.Socket; import java.nio.charset.StandardCharsets; -import com.google.common.annotations.VisibleForTesting; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.annotations.VisibleForTesting; /** * 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 df92bfc703..8435fbf0ca 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java @@ -31,14 +31,12 @@ import java.util.Collection; import java.util.Date; import java.util.Map.Entry; - import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; 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; diff --git a/src/main/java/org/opensearch/security/support/Base64CustomHelper.java b/src/main/java/org/opensearch/security/support/Base64CustomHelper.java index dc66268fcd..2bb3913307 100644 --- a/src/main/java/org/opensearch/security/support/Base64CustomHelper.java +++ b/src/main/java/org/opensearch/security/support/Base64CustomHelper.java @@ -11,23 +11,24 @@ package org.opensearch.security.support; -import com.amazon.dlic.auth.ldap.LdapUser; +import java.io.IOException; +import java.io.Serializable; + import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.io.BaseEncoding; import org.opensearch.OpenSearchException; import org.opensearch.common.Nullable; -import org.opensearch.core.common.io.stream.BytesStreamInput; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.io.stream.BytesStreamInput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.core.common.Strings; import org.opensearch.security.auth.UserInjector; import org.opensearch.security.user.User; -import java.io.IOException; -import java.io.Serializable; +import com.amazon.dlic.auth.ldap.LdapUser; import static org.opensearch.security.support.SafeSerializationUtils.prohibitUnsafeClasses; diff --git a/src/main/java/org/opensearch/security/support/Base64JDKHelper.java b/src/main/java/org/opensearch/security/support/Base64JDKHelper.java index a4ab87d813..cb0705b02f 100644 --- a/src/main/java/org/opensearch/security/support/Base64JDKHelper.java +++ b/src/main/java/org/opensearch/security/support/Base64JDKHelper.java @@ -41,7 +41,6 @@ import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; - import org.opensearch.OpenSearchException; import org.opensearch.SpecialPermission; import org.opensearch.core.common.Strings; diff --git a/src/main/java/org/opensearch/security/support/ConfigConstants.java b/src/main/java/org/opensearch/security/support/ConfigConstants.java index 1f5728edfb..34e64653a1 100644 --- a/src/main/java/org/opensearch/security/support/ConfigConstants.java +++ b/src/main/java/org/opensearch/security/support/ConfigConstants.java @@ -34,7 +34,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - import org.opensearch.Version; import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditCategory; diff --git a/src/main/java/org/opensearch/security/support/ConfigHelper.java b/src/main/java/org/opensearch/security/support/ConfigHelper.java index 434a8a02fa..589c93827b 100644 --- a/src/main/java/org/opensearch/security/support/ConfigHelper.java +++ b/src/main/java/org/opensearch/security/support/ConfigHelper.java @@ -37,14 +37,13 @@ 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; import org.opensearch.client.Client; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/security/support/GuardedSearchOperationWrapper.java b/src/main/java/org/opensearch/security/support/GuardedSearchOperationWrapper.java index cc0cf06ce2..20283ea284 100644 --- a/src/main/java/org/opensearch/security/support/GuardedSearchOperationWrapper.java +++ b/src/main/java/org/opensearch/security/support/GuardedSearchOperationWrapper.java @@ -13,7 +13,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.index.shard.SearchOperationListener; import org.opensearch.search.internal.ReaderContext; import org.opensearch.search.internal.SearchContext; diff --git a/src/main/java/org/opensearch/security/support/HeaderHelper.java b/src/main/java/org/opensearch/security/support/HeaderHelper.java index bbb44664fa..d0de40c1f2 100644 --- a/src/main/java/org/opensearch/security/support/HeaderHelper.java +++ b/src/main/java/org/opensearch/security/support/HeaderHelper.java @@ -31,7 +31,6 @@ import java.util.List; import com.google.common.base.Strings; - import org.opensearch.common.util.concurrent.ThreadContext; public class HeaderHelper { diff --git a/src/main/java/org/opensearch/security/support/ModuleInfo.java b/src/main/java/org/opensearch/security/support/ModuleInfo.java index a225aee3be..e8c3e101ab 100644 --- a/src/main/java/org/opensearch/security/support/ModuleInfo.java +++ b/src/main/java/org/opensearch/security/support/ModuleInfo.java @@ -26,15 +26,15 @@ package org.opensearch.security.support; -import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.core.common.io.stream.Writeable; - import java.io.IOException; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.common.io.stream.Writeable; + public class ModuleInfo implements Serializable, Writeable { private static final long serialVersionUID = -1077651823194285138L; diff --git a/src/main/java/org/opensearch/security/support/PemKeyReader.java b/src/main/java/org/opensearch/security/support/PemKeyReader.java index 4227c2129b..9502c955a4 100644 --- a/src/main/java/org/opensearch/security/support/PemKeyReader.java +++ b/src/main/java/org/opensearch/security/support/PemKeyReader.java @@ -51,7 +51,6 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Collection; - import javax.crypto.Cipher; import javax.crypto.EncryptedPrivateKeyInfo; import javax.crypto.NoSuchPaddingException; @@ -61,7 +60,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.bouncycastle.util.io.pem.PemObject; import org.bouncycastle.util.io.pem.PemReader; import org.opensearch.OpenSearchException; diff --git a/src/main/java/org/opensearch/security/support/ReflectionHelper.java b/src/main/java/org/opensearch/security/support/ReflectionHelper.java index 9693f383f0..d0c0220288 100644 --- a/src/main/java/org/opensearch/security/support/ReflectionHelper.java +++ b/src/main/java/org/opensearch/security/support/ReflectionHelper.java @@ -37,7 +37,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/support/SafeSerializationUtils.java b/src/main/java/org/opensearch/security/support/SafeSerializationUtils.java index c980959f68..c0c2ae17cb 100644 --- a/src/main/java/org/opensearch/security/support/SafeSerializationUtils.java +++ b/src/main/java/org/opensearch/security/support/SafeSerializationUtils.java @@ -11,16 +11,6 @@ package org.opensearch.security.support; -import com.amazon.dlic.auth.ldap.LdapUser; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import org.ldaptive.AbstractLdapBean; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.SearchEntry; -import org.opensearch.security.auth.UserInjector; -import org.opensearch.security.user.User; - import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -32,6 +22,17 @@ import java.util.Set; import java.util.regex.Pattern; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.opensearch.security.auth.UserInjector; +import org.opensearch.security.user.User; + +import com.amazon.dlic.auth.ldap.LdapUser; +import org.ldaptive.AbstractLdapBean; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.SearchEntry; + /** * Provides functionality to verify if a class is categorised to be safe for serialization or * deserialization by the security plugin. diff --git a/src/main/java/org/opensearch/security/support/SecurityJsonNode.java b/src/main/java/org/opensearch/security/support/SecurityJsonNode.java index 04a6fabf5c..1f3705833e 100644 --- a/src/main/java/org/opensearch/security/support/SecurityJsonNode.java +++ b/src/main/java/org/opensearch/security/support/SecurityJsonNode.java @@ -24,7 +24,6 @@ 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 1df5f23637..aae4967edb 100644 --- a/src/main/java/org/opensearch/security/support/SecurityUtils.java +++ b/src/main/java/org/opensearch/security/support/SecurityUtils.java @@ -36,7 +36,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.Settings; import org.opensearch.security.tools.Hasher; diff --git a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java index 2c85177c1e..bb20224f7e 100644 --- a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java +++ b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java @@ -33,7 +33,6 @@ 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; diff --git a/src/main/java/org/opensearch/security/support/StreamableRegistry.java b/src/main/java/org/opensearch/security/support/StreamableRegistry.java index bfde866376..3c323ebe7e 100644 --- a/src/main/java/org/opensearch/security/support/StreamableRegistry.java +++ b/src/main/java/org/opensearch/security/support/StreamableRegistry.java @@ -19,7 +19,6 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; - import org.opensearch.OpenSearchException; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java b/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java index b01335a58f..619cf66a93 100644 --- a/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java +++ b/src/main/java/org/opensearch/security/tools/AuditConfigMigrater.java @@ -17,14 +17,13 @@ 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; 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 com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ToXContent; diff --git a/src/main/java/org/opensearch/security/tools/Migrater.java b/src/main/java/org/opensearch/security/tools/Migrater.java index 96b79a5993..c41b9796ad 100644 --- a/src/main/java/org/opensearch/security/tools/Migrater.java +++ b/src/main/java/org/opensearch/security/tools/Migrater.java @@ -19,14 +19,13 @@ import java.io.File; -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 com.google.common.io.Files; import org.opensearch.common.collect.Tuple; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.securityconf.Migration; diff --git a/src/main/java/org/opensearch/security/tools/SecurityAdmin.java b/src/main/java/org/opensearch/security/tools/SecurityAdmin.java index ec877bb2cb..b2c5d4e77e 100644 --- a/src/main/java/org/opensearch/security/tools/SecurityAdmin.java +++ b/src/main/java/org/opensearch/security/tools/SecurityAdmin.java @@ -51,19 +51,12 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; - import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Charsets; -import com.google.common.base.Joiner; -import com.google.common.collect.Iterators; -import com.google.common.io.ByteSource; -import com.google.common.io.CharStreams; -import com.google.common.io.Files; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -82,7 +75,12 @@ import org.apache.hc.core5.reactor.ssl.TlsDetails; import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.hc.core5.ssl.SSLContexts; - +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.collect.Iterators; +import com.google.common.io.ByteSource; +import com.google.common.io.CharStreams; +import com.google.common.io.Files; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchStatusException; @@ -109,21 +107,21 @@ import org.opensearch.client.indices.GetIndexResponse; import org.opensearch.client.transport.NoNodeAvailableException; import org.opensearch.cluster.health.ClusterHealthStatus; -import org.opensearch.core.common.Strings; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.IndexNotFoundException; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.NonValidatingObjectMapper; import org.opensearch.security.auditlog.config.AuditConfig; diff --git a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java index 8b3bb0a85e..810b92a7c8 100644 --- a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java +++ b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java @@ -37,8 +37,6 @@ 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.security.securityconf.DynamicConfigFactory; @@ -47,6 +45,8 @@ import org.opensearch.security.support.WildcardMatcher; import org.opensearch.transport.TransportRequest; +import org.greenrobot.eventbus.Subscribe; + public final class DefaultInterClusterRequestEvaluator implements InterClusterRequestEvaluator { private final Logger log = LogManager.getLogger(this.getClass()); diff --git a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java index f064f0af04..7ec5e1518c 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java +++ b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java @@ -33,11 +33,10 @@ import java.util.UUID; import java.util.stream.Collectors; -import com.google.common.collect.Maps; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.Maps; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.opensearch.action.get.GetRequest; @@ -45,10 +44,11 @@ import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.transport.TransportAddress; +import org.opensearch.core.transport.TransportResponse; import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.auditlog.AuditLog.Origin; @@ -68,7 +68,6 @@ import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportRequestHandler; import org.opensearch.transport.TransportRequestOptions; -import org.opensearch.core.transport.TransportResponse; import org.opensearch.transport.TransportResponseHandler; import static org.opensearch.security.OpenSearchSecurityPlugin.isActionTraceEnabled; diff --git a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java index 3ba379dd67..55f1867bf9 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java +++ b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java @@ -34,14 +34,13 @@ import java.util.stream.Collectors; import com.google.common.base.Strings; - import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.bulk.BulkShardRequest; import org.opensearch.action.support.replication.TransportReplicationAction.ConcreteShardRequest; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.security.OpenSearchSecurityPlugin; diff --git a/src/main/java/org/opensearch/security/user/User.java b/src/main/java/org/opensearch/security/user/User.java index aa9c09a469..40394ebf51 100644 --- a/src/main/java/org/opensearch/security/user/User.java +++ b/src/main/java/org/opensearch/security/user/User.java @@ -37,7 +37,6 @@ import java.util.Set; import com.google.common.collect.Lists; - import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; diff --git a/src/main/java/org/opensearch/security/user/UserService.java b/src/main/java/org/opensearch/security/user/UserService.java index e7c30b97b0..9fbc426e5c 100644 --- a/src/main/java/org/opensearch/security/user/UserService.java +++ b/src/main/java/org/opensearch/security/user/UserService.java @@ -27,10 +27,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +import com.google.common.collect.ImmutableList; import org.opensearch.ExceptionsHelper; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest; @@ -52,6 +51,7 @@ import org.opensearch.security.securityconf.impl.v7.InternalUserV7; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.SecurityJsonNode; + import org.passay.CharacterRule; import org.passay.EnglishCharacterData; import org.passay.PasswordGenerator; diff --git a/src/main/java/org/opensearch/security/util/KeyUtils.java b/src/main/java/org/opensearch/security/util/KeyUtils.java index c232dda3a2..8f2a658e29 100644 --- a/src/main/java/org/opensearch/security/util/KeyUtils.java +++ b/src/main/java/org/opensearch/security/util/KeyUtils.java @@ -11,14 +11,6 @@ package org.opensearch.security.util; -import io.jsonwebtoken.JwtParserBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.security.Keys; -import org.apache.logging.log4j.Logger; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.core.common.Strings; - import java.security.AccessController; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; @@ -29,6 +21,15 @@ import java.util.Base64; import java.util.Objects; +import org.apache.logging.log4j.Logger; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.core.common.Strings; + +import io.jsonwebtoken.JwtParserBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; + public class KeyUtils { public static JwtParserBuilder createJwtParserBuilderFromSigningKey(final String signingKey, final Logger log) { 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 40b1f622d0..87f747b87b 100644 --- a/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java +++ b/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java @@ -21,12 +21,12 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; 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 4f141994e3..aa56e6fe3d 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 @@ -21,23 +21,22 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; - import javax.crypto.SecretKey; -import com.google.common.io.BaseEncoding; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import io.jsonwebtoken.security.Keys; import org.apache.hc.core5.http.HttpHeaders; import org.junit.Assert; import org.junit.Test; - +import com.google.common.io.BaseEncoding; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; + import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; 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 a31e30db39..65deafc66b 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 @@ -13,12 +13,11 @@ import java.util.HashMap; import java.util.List; -import com.google.common.collect.ImmutableMap; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; 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 273cadca08..1c580abc9d 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 @@ -18,11 +18,9 @@ import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; import java.util.Map; - import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSession; -import com.google.common.hash.Hashing; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; @@ -36,12 +34,12 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; - -import com.amazon.dlic.util.SettingsBasedSSLConfigurator; - +import com.google.common.hash.Hashing; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; +import com.amazon.dlic.util.SettingsBasedSSLConfigurator; + 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 20c71b0340..af77aa0f8b 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 @@ -18,13 +18,11 @@ import java.net.Socket; import java.security.GeneralSecurityException; import java.security.KeyStore; - import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; import javax.net.ssl.TrustManagerFactory; -import com.nimbusds.jose.jwk.JWKSet; import org.apache.hc.core5.function.Callback; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; @@ -38,10 +36,11 @@ import org.apache.hc.core5.http.io.HttpRequestHandler; import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.http.protocol.HttpContext; - import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; +import com.nimbusds.jose.jwk.JWKSet; + 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 ba7f65b7ee..bab23c5fc4 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 @@ -15,11 +15,12 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; +import org.junit.Assert; +import org.junit.Test; + import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.JWKSet; import com.nimbusds.jose.jwk.OctetSequenceKey; -import org.junit.Assert; -import org.junit.Test; public class SelfRefreshingKeySetTest { 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 196e91be21..d9a80b7de9 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 @@ -14,10 +14,9 @@ import java.util.HashMap; import java.util.List; -import com.google.common.collect.ImmutableMap; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; 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 9d49596e73..76cc038743 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 @@ -13,7 +13,9 @@ import java.util.Set; +import org.apache.logging.log4j.util.Strings; import com.google.common.collect.ImmutableSet; + import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSHeader; @@ -22,7 +24,6 @@ import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; -import org.apache.logging.log4j.util.Strings; import static com.nimbusds.jwt.JWTClaimNames.EXPIRATION_TIME; import static com.nimbusds.jwt.JWTClaimNames.NOT_BEFORE; 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 bbb0850392..2a0ca74973 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 @@ -29,41 +29,40 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.net.ssl.KeyManagerFactory; import com.fasterxml.jackson.core.type.TypeReference; -import com.google.common.collect.ImmutableMap; -import com.nimbusds.jwt.SignedJWT; import org.hamcrest.Matchers; 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.core.common.bytes.BytesArray; +import com.google.common.collect.ImmutableMap; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestResponse; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.DefaultObjectMapper; +import org.opensearch.security.filter.SecurityRequest; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.filter.SecurityResponse; -import org.opensearch.security.filter.SecurityRequest; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; +import com.nimbusds.jwt.SignedJWT; +import org.opensaml.saml.saml2.core.NameIDType; + +import static org.hamcrest.MatcherAssert.assertThat; import static com.amazon.dlic.auth.http.saml.HTTPSamlAuthenticator.IDP_METADATA_CONTENT; import static com.amazon.dlic.auth.http.saml.HTTPSamlAuthenticator.IDP_METADATA_URL; -import static org.hamcrest.MatcherAssert.assertThat; public class HTTPSamlAuthenticatorTest { protected MockSamlIdpServer mockSamlIdpServer; 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 c984b4f670..c20ad7af52 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 @@ -42,7 +42,6 @@ import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; - import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -62,9 +61,6 @@ 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.codec.EncodingException; -import net.shibboleth.utilities.java.support.component.ComponentInitializationException; import org.apache.hc.core5.function.Callback; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; @@ -86,6 +82,12 @@ import org.apache.hc.core5.http.message.BasicHttpRequest; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.net.URIBuilder; +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.codec.EncodingException; +import net.shibboleth.utilities.java.support.component.ComponentInitializationException; import org.opensaml.core.xml.XMLObject; import org.opensaml.core.xml.XMLObjectBuilderFactory; import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport; @@ -150,9 +152,6 @@ import org.opensaml.xmlsec.signature.support.impl.ExplicitKeySignatureTrustEngine; import org.w3c.dom.Document; -import org.opensearch.security.test.helper.file.FileHelper; -import org.opensearch.security.test.helper.network.SocketUtils; - 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 f9af873ec2..7693089477 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendIntegTest.java @@ -17,9 +17,6 @@ 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; @@ -28,6 +25,8 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; + public class LdapBackendIntegTest extends SingleClusterTest { private static EmbeddedLDAPServer ldapServer = null; 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 4bbf94f729..029cc50163 100755 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTest.java @@ -20,17 +20,6 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.ldaptive.Connection; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.ReturnAttributes; - -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 org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; @@ -38,6 +27,16 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +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 org.ldaptive.Connection; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.ReturnAttributes; + import static org.hamcrest.Matchers.hasItem; public class LdapBackendTest { 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 1765b5fd26..4ddf91df1c 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestClientCert.java @@ -20,15 +20,14 @@ 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; +import com.amazon.dlic.auth.ldap.backend.LDAPAuthenticationBackend; +import com.amazon.dlic.auth.ldap.util.ConfigConstants; + @Ignore public class LdapBackendTestClientCert { 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 3026ffcd61..55a848c2e3 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java +++ b/src/test/java/com/amazon/dlic/auth/ldap/LdapBackendTestNewStyleConfig.java @@ -21,16 +21,6 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.ldaptive.Connection; -import org.ldaptive.LdapEntry; -import org.ldaptive.ReturnAttributes; - -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 org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; @@ -38,6 +28,15 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +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 org.ldaptive.Connection; +import org.ldaptive.LdapEntry; +import org.ldaptive.ReturnAttributes; + import static org.hamcrest.Matchers.hasItem; public class LdapBackendTestNewStyleConfig { 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 bb7738d3fd..f6129c13f7 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 @@ -24,7 +24,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.google.common.io.CharStreams; +import org.opensearch.security.test.helper.file.FileHelper; +import org.opensearch.security.test.helper.network.SocketUtils; + import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; import com.unboundid.ldap.listener.InMemoryListenerConfig; @@ -36,12 +42,6 @@ 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 2f5269fe48..4ab952606d 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendIntegTest2.java @@ -17,9 +17,6 @@ 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; @@ -28,6 +25,8 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import com.amazon.dlic.auth.ldap.srv.EmbeddedLDAPServer; + public class LdapBackendIntegTest2 extends SingleClusterTest { private static EmbeddedLDAPServer ldapServer = null; 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 6ba7a84b4a..060c9bba09 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestClientCert2.java @@ -20,15 +20,14 @@ 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; +import com.amazon.dlic.auth.ldap.LdapUser; +import com.amazon.dlic.auth.ldap.util.ConfigConstants; + @Ignore public class LdapBackendTestClientCert2 { 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 4bd9f92083..04c03429e0 100644 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestNewStyleConfig2.java @@ -27,18 +27,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.ldaptive.Connection; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.ReturnAttributes; - -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 org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; @@ -47,6 +35,17 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +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 org.ldaptive.Connection; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.ReturnAttributes; + import static org.hamcrest.Matchers.hasItem; @RunWith(Parameterized.class) 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 7f7d6646b2..2c820ff433 100755 --- a/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java +++ b/src/test/java/com/amazon/dlic/auth/ldap2/LdapBackendTestOldStyleConfig2.java @@ -27,18 +27,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.ldaptive.Connection; -import org.ldaptive.LdapAttribute; -import org.ldaptive.LdapEntry; -import org.ldaptive.ReturnAttributes; - -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 org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; @@ -47,6 +35,17 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; +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 org.ldaptive.Connection; +import org.ldaptive.LdapAttribute; +import org.ldaptive.LdapEntry; +import org.ldaptive.ReturnAttributes; + import static org.hamcrest.Matchers.hasItem; @RunWith(Parameterized.class) diff --git a/src/test/java/org/opensearch/node/PluginAwareNode.java b/src/test/java/org/opensearch/node/PluginAwareNode.java index 19cda27e81..d992017c27 100644 --- a/src/test/java/org/opensearch/node/PluginAwareNode.java +++ b/src/test/java/org/opensearch/node/PluginAwareNode.java @@ -26,12 +26,12 @@ package org.opensearch.node; -import org.opensearch.common.settings.Settings; -import org.opensearch.plugins.Plugin; - import java.util.Collection; import java.util.Collections; +import org.opensearch.common.settings.Settings; +import org.opensearch.plugins.Plugin; + public class PluginAwareNode extends Node { private final boolean clusterManagerEligible; diff --git a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java index e8ac049385..3f4a07c583 100644 --- a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java +++ b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java @@ -20,7 +20,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.SingleClusterTest; diff --git a/src/test/java/org/opensearch/security/AggregationTests.java b/src/test/java/org/opensearch/security/AggregationTests.java index a61d5d169d..d5ec6b260a 100644 --- a/src/test/java/org/opensearch/security/AggregationTests.java +++ b/src/test/java/org/opensearch/security/AggregationTests.java @@ -29,7 +29,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/ConfigTests.java b/src/test/java/org/opensearch/security/ConfigTests.java index 4815f5a9b7..07eefeb0a9 100644 --- a/src/test/java/org/opensearch/security/ConfigTests.java +++ b/src/test/java/org/opensearch/security/ConfigTests.java @@ -26,7 +26,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.collect.Tuple; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; diff --git a/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java b/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java index 773244c7ea..1599acacdd 100644 --- a/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java +++ b/src/test/java/org/opensearch/security/DataStreamIntegrationTests.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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 462cd591e6..3a72db8fb4 100644 --- a/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java +++ b/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java @@ -13,7 +13,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/HealthTests.java b/src/test/java/org/opensearch/security/HealthTests.java index c36440f1a2..0aa32a9e32 100644 --- a/src/test/java/org/opensearch/security/HealthTests.java +++ b/src/test/java/org/opensearch/security/HealthTests.java @@ -29,7 +29,6 @@ import org.apache.hc.core5.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/HttpIntegrationTests.java b/src/test/java/org/opensearch/security/HttpIntegrationTests.java index 94994875d8..0a184c754e 100644 --- a/src/test/java/org/opensearch/security/HttpIntegrationTests.java +++ b/src/test/java/org/opensearch/security/HttpIntegrationTests.java @@ -26,6 +26,10 @@ package org.opensearch.security; +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + import com.fasterxml.jackson.databind.JsonNode; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.NoHttpResponseException; @@ -52,10 +56,6 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; - import static org.opensearch.security.DefaultObjectMapper.readTree; public class HttpIntegrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/IndexIntegrationTests.java b/src/test/java/org/opensearch/security/IndexIntegrationTests.java index 3d024f28f7..7850420ac1 100644 --- a/src/test/java/org/opensearch/security/IndexIntegrationTests.java +++ b/src/test/java/org/opensearch/security/IndexIntegrationTests.java @@ -35,7 +35,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/IndexTemplateClusterPermissionsCheckTest.java b/src/test/java/org/opensearch/security/IndexTemplateClusterPermissionsCheckTest.java index 03d26e2062..8acf420507 100644 --- a/src/test/java/org/opensearch/security/IndexTemplateClusterPermissionsCheckTest.java +++ b/src/test/java/org/opensearch/security/IndexTemplateClusterPermissionsCheckTest.java @@ -15,7 +15,6 @@ import org.junit.Assert; import org.junit.Before; 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/InitializationIntegrationTests.java b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java index 78b03a5fab..7e71ab9579 100644 --- a/src/test/java/org/opensearch/security/InitializationIntegrationTests.java +++ b/src/test/java/org/opensearch/security/InitializationIntegrationTests.java @@ -37,7 +37,6 @@ import org.apache.hc.core5.http2.HttpVersionPolicy; 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; diff --git a/src/test/java/org/opensearch/security/IntegrationTests.java b/src/test/java/org/opensearch/security/IntegrationTests.java index 9a4bf7bba8..7ac60622fe 100644 --- a/src/test/java/org/opensearch/security/IntegrationTests.java +++ b/src/test/java/org/opensearch/security/IntegrationTests.java @@ -29,13 +29,11 @@ import java.util.TreeSet; import com.fasterxml.jackson.databind.JsonNode; -import io.netty.handler.ssl.OpenSsl; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.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; @@ -57,6 +55,8 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; +import io.netty.handler.ssl.OpenSsl; + import static org.opensearch.security.DefaultObjectMapper.readTree; public class IntegrationTests extends SingleClusterTest { diff --git a/src/test/java/org/opensearch/security/PitIntegrationTests.java b/src/test/java/org/opensearch/security/PitIntegrationTests.java index 035cc2ce3e..ce952f26d0 100644 --- a/src/test/java/org/opensearch/security/PitIntegrationTests.java +++ b/src/test/java/org/opensearch/security/PitIntegrationTests.java @@ -16,7 +16,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; diff --git a/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java b/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java index b7af395daa..7fa65eb688 100644 --- a/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java +++ b/src/test/java/org/opensearch/security/PrivilegesEvaluationTest.java @@ -11,10 +11,9 @@ package org.opensearch.security; -import com.google.common.collect.ImmutableMap; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; diff --git a/src/test/java/org/opensearch/security/ResolveAPITests.java b/src/test/java/org/opensearch/security/ResolveAPITests.java index 088702acd9..0b0471b9d3 100644 --- a/src/test/java/org/opensearch/security/ResolveAPITests.java +++ b/src/test/java/org/opensearch/security/ResolveAPITests.java @@ -20,7 +20,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java index c4abf42904..11fcdd23d0 100644 --- a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java @@ -20,10 +20,9 @@ import java.util.Collection; import java.util.function.Supplier; -import com.google.common.collect.Lists; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; @@ -34,8 +33,8 @@ import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; diff --git a/src/test/java/org/opensearch/security/RolesValidationIntegTest.java b/src/test/java/org/opensearch/security/RolesValidationIntegTest.java index 9c8f52fa3e..3616e96cfa 100644 --- a/src/test/java/org/opensearch/security/RolesValidationIntegTest.java +++ b/src/test/java/org/opensearch/security/RolesValidationIntegTest.java @@ -16,10 +16,9 @@ import java.util.Collection; import java.util.function.Supplier; -import com.google.common.collect.Lists; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; @@ -28,8 +27,8 @@ import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; diff --git a/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java b/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java index b8da89e2dc..a4b5b92411 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminIEndpointsTests.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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 6cb89dc18f..0b0ca3883c 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminInvalidConfigsTests.java @@ -33,7 +33,6 @@ import org.apache.hc.core5.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/SecurityAdminTests.java b/src/test/java/org/opensearch/security/SecurityAdminTests.java index 760f2a33d7..d736a9a456 100644 --- a/src/test/java/org/opensearch/security/SecurityAdminTests.java +++ b/src/test/java/org/opensearch/security/SecurityAdminTests.java @@ -28,7 +28,6 @@ import org.apache.hc.core5.http.HttpStatus; 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.support.ConfigConstants; diff --git a/src/test/java/org/opensearch/security/SecurityRolesTests.java b/src/test/java/org/opensearch/security/SecurityRolesTests.java index 24a6bafbb8..e8a4a06a97 100644 --- a/src/test/java/org/opensearch/security/SecurityRolesTests.java +++ b/src/test/java/org/opensearch/security/SecurityRolesTests.java @@ -30,7 +30,6 @@ import org.apache.hc.core5.http.message.BasicHeader; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.DynamicSecurityConfig; diff --git a/src/test/java/org/opensearch/security/SlowIntegrationTests.java b/src/test/java/org/opensearch/security/SlowIntegrationTests.java index 28ec9f8d88..60c28a00a2 100644 --- a/src/test/java/org/opensearch/security/SlowIntegrationTests.java +++ b/src/test/java/org/opensearch/security/SlowIntegrationTests.java @@ -28,11 +28,10 @@ import java.io.IOException; -import com.google.common.collect.Lists; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; 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; diff --git a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java index 1c884a8e5d..681045c0f5 100644 --- a/src/test/java/org/opensearch/security/SnapshotRestoreTests.java +++ b/src/test/java/org/opensearch/security/SnapshotRestoreTests.java @@ -32,7 +32,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; 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.create.CreateIndexRequest; diff --git a/src/test/java/org/opensearch/security/SystemIntegratorsTests.java b/src/test/java/org/opensearch/security/SystemIntegratorsTests.java index 27e44b1ce5..33ac2667e8 100644 --- a/src/test/java/org/opensearch/security/SystemIntegratorsTests.java +++ b/src/test/java/org/opensearch/security/SystemIntegratorsTests.java @@ -26,12 +26,11 @@ package org.opensearch.security; -import com.google.common.collect.Lists; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.message.BasicHeader; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.SingleClusterTest; diff --git a/src/test/java/org/opensearch/security/TaskTests.java b/src/test/java/org/opensearch/security/TaskTests.java index 39bb21f164..545b0621d6 100644 --- a/src/test/java/org/opensearch/security/TaskTests.java +++ b/src/test/java/org/opensearch/security/TaskTests.java @@ -21,7 +21,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/TracingTests.java b/src/test/java/org/opensearch/security/TracingTests.java index 55dccdee35..99c6239353 100644 --- a/src/test/java/org/opensearch/security/TracingTests.java +++ b/src/test/java/org/opensearch/security/TracingTests.java @@ -30,7 +30,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java index f97919b2f7..1c3da9057e 100644 --- a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java @@ -16,18 +16,17 @@ import java.util.Collection; import java.util.function.Supplier; -import com.google.common.collect.Lists; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; diff --git a/src/test/java/org/opensearch/security/UserServiceUnitTests.java b/src/test/java/org/opensearch/security/UserServiceUnitTests.java index 6bdef8d167..e8248fbff7 100644 --- a/src/test/java/org/opensearch/security/UserServiceUnitTests.java +++ b/src/test/java/org/opensearch/security/UserServiceUnitTests.java @@ -11,12 +11,16 @@ package org.opensearch.security; +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -26,11 +30,7 @@ import org.opensearch.security.user.UserFilterType; import org.opensearch.security.user.UserService; -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; - -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import org.mockito.Mock; public class UserServiceUnitTests { SecurityDynamicConfiguration config; diff --git a/src/test/java/org/opensearch/security/UtilTests.java b/src/test/java/org/opensearch/security/UtilTests.java index f64c905667..cf9d5232f3 100644 --- a/src/test/java/org/opensearch/security/UtilTests.java +++ b/src/test/java/org/opensearch/security/UtilTests.java @@ -28,9 +28,8 @@ import java.util.Map; -import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.junit.Test; - +import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.SecurityUtils; diff --git a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java index bad71c75f4..360be3900b 100644 --- a/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java +++ b/src/test/java/org/opensearch/security/auditlog/AbstractAuditlogiUnitTest.java @@ -11,6 +11,9 @@ package org.opensearch.security.auditlog; +import java.util.Arrays; +import java.util.Collection; + import com.fasterxml.jackson.databind.JsonNode; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; @@ -22,9 +25,6 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; -import java.util.Arrays; -import java.util.Collection; - import static org.opensearch.security.auditlog.config.AuditConfig.DEPRECATED_KEYS; 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 98f5fab88e..8e3106b3bd 100644 --- a/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java +++ b/src/test/java/org/opensearch/security/auditlog/AuditTestUtils.java @@ -16,7 +16,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.hc.core5.http.HttpStatus; - import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; 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 773180bd1b..73d3e2d747 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceAuditlogTest.java @@ -16,12 +16,11 @@ import java.util.List; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; import org.opensearch.action.index.IndexRequest; 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 467475212b..b7d5e8fc94 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/ComplianceConfigTest.java @@ -13,9 +13,8 @@ import java.util.Collections; -import com.google.common.collect.ImmutableSet; import org.junit.Test; - +import com.google.common.collect.ImmutableSet; import org.opensearch.common.settings.Settings; import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.support.ConfigConstants; 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 cf06726ea1..9dec3075f3 100644 --- a/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/compliance/RestApiComplianceAuditlogTest.java @@ -15,7 +15,6 @@ 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; 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 fad4cabbc5..39012cbbab 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigFilterTest.java @@ -17,9 +17,8 @@ import java.util.Set; import java.util.function.Function; -import com.google.common.collect.ImmutableSet; import org.junit.Test; - +import com.google.common.collect.ImmutableSet; import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.config.AuditConfig.Filter.FilterEntries; import org.opensearch.security.auditlog.impl.AuditCategory; @@ -28,16 +27,16 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -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.BAD_HEADERS; 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.opensearch.security.auditlog.impl.AuditCategory.SSL_EXCEPTION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; 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 33dad63e5f..1b86c2b303 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/AuditConfigSerializeTest.java @@ -19,11 +19,10 @@ 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 com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentBuilder; @@ -32,12 +31,12 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; +import static org.opensearch.security.auditlog.impl.AuditCategory.AUTHENTICATED; +import static org.opensearch.security.auditlog.impl.AuditCategory.GRANTED_PRIVILEGES; 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; 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 83c5e9ae2a..33a331112a 100644 --- a/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java +++ b/src/test/java/org/opensearch/security/auditlog/config/ThreadPoolConfigTest.java @@ -14,7 +14,6 @@ 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; 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 f53872bb3a..03ff7a1908 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditMessageTest.java @@ -16,17 +16,16 @@ 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 com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.securityconf.impl.CType; 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 935fb924a3..3326c1ac22 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/AuditlogTest.java @@ -14,7 +14,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.ClusterName; 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 fa176a2011..34890c2c87 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/DelegateTest.java @@ -12,7 +12,6 @@ package org.opensearch.security.auditlog.impl; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.Settings.Builder; import org.opensearch.security.auditlog.helper.MyOwnAuditLog; 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 ba4ee7b55d..bfd12b9bba 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/DisabledCategoriesTest.java @@ -16,13 +16,12 @@ import java.util.LinkedList; import java.util.List; -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 com.google.common.base.Joiner; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; 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 8e33401c69..bf7657176c 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/IgnoreAuditUsersTest.java @@ -17,7 +17,6 @@ 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; 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 15728537e2..abf808dcee 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 6c1812c32b..c49884680e 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java @@ -14,13 +14,12 @@ import java.util.Collections; import java.util.List; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.message.BasicHeader; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; 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; 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 82c56d4b23..99d49085d9 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/SSLAuditlogTest.java @@ -15,7 +15,6 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; import org.opensearch.security.support.ConfigConstants; 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 cf76dbc343..ba6c0f1e79 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/FallbackTest.java @@ -18,7 +18,6 @@ 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; 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 f308db21fc..fff2d26783 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/PerfTest.java @@ -14,7 +14,6 @@ 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; 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 9ab7c0f93c..45e301449a 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/RouterTest.java @@ -17,7 +17,6 @@ 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; 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 8ddb79bcba..c53b7ff3af 100644 --- a/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java +++ b/src/test/java/org/opensearch/security/auditlog/routing/RoutingConfigurationTest.java @@ -16,7 +16,6 @@ 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; 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 bf567c6ebe..17853d16da 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/KafkaSinkTest.java @@ -22,8 +22,6 @@ import org.junit.Assert; import org.junit.ClassRule; import org.junit.Test; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.yaml.YamlXContent; import org.opensearch.security.auditlog.AbstractAuditlogiUnitTest; @@ -31,6 +29,8 @@ import org.opensearch.security.auditlog.impl.AuditCategory; import org.opensearch.security.test.helper.file.FileHelper; +import org.springframework.kafka.test.rule.EmbeddedKafkaRule; + public class KafkaSinkTest extends AbstractAuditlogiUnitTest { @ClassRule 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 49853a05fa..e23e3a2c0d 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTLSTest.java @@ -16,7 +16,6 @@ import java.io.InputStream; import java.net.ServerSocket; import java.security.KeyStore; - import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; @@ -28,7 +27,6 @@ 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; 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 5e3203261f..84ac3b8924 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/SinkProviderTest.java @@ -14,7 +14,6 @@ import org.apache.logging.log4j.Level; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.test.helper.file.FileHelper; 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 28469d1a9b..d8819784f0 100644 --- a/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/sink/WebhookAuditLogTest.java @@ -19,7 +19,6 @@ import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.Objects; - import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; @@ -33,7 +32,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.helper.LoggingSink; import org.opensearch.security.auditlog.helper.MockAuditMessageFactory; diff --git a/src/test/java/org/opensearch/security/auth/InternalAuthBackendTests.java b/src/test/java/org/opensearch/security/auth/InternalAuthBackendTests.java index c059c890ab..2e33b517ae 100644 --- a/src/test/java/org/opensearch/security/auth/InternalAuthBackendTests.java +++ b/src/test/java/org/opensearch/security/auth/InternalAuthBackendTests.java @@ -19,13 +19,13 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; - import org.opensearch.OpenSearchSecurityException; import org.opensearch.security.auth.internal.InternalAuthenticationBackend; import org.opensearch.security.securityconf.InternalUsersModel; import org.opensearch.security.user.AuthCredentials; +import org.mockito.Mockito; + import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; diff --git a/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java b/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java index 63eb32f862..2635463556 100644 --- a/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java +++ b/src/test/java/org/opensearch/security/auth/RolesInjectorTest.java @@ -21,7 +21,6 @@ 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; @@ -30,9 +29,9 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; +import static org.opensearch.security.support.ConfigConstants.OPENDISTRO_SECURITY_INJECTED_ROLES; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -import static org.opensearch.security.support.ConfigConstants.OPENDISTRO_SECURITY_INJECTED_ROLES; 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 df89b09981..cf71d74c8d 100644 --- a/src/test/java/org/opensearch/security/auth/UserInjectorTest.java +++ b/src/test/java/org/opensearch/security/auth/UserInjectorTest.java @@ -17,8 +17,6 @@ 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; @@ -29,6 +27,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportRequest; +import org.mockito.Mockito; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; 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 69ddc5c03a..66099d64e4 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/AddressBasedRateLimiterTest.java @@ -17,12 +17,11 @@ package org.opensearch.security.auth.limiting; -import org.junit.Test; +import java.net.InetAddress; +import org.junit.Test; import org.opensearch.common.settings.Settings; -import java.net.InetAddress; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; 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 c92c328564..981a0dbbad 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/HeapBasedRateTrackerTest.java @@ -19,7 +19,6 @@ import org.junit.Ignore; import org.junit.Test; - import org.opensearch.security.util.ratetracking.HeapBasedRateTracker; import static org.junit.Assert.assertFalse; 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 a8285c42a7..ad5eba14d5 100644 --- a/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java +++ b/src/test/java/org/opensearch/security/auth/limiting/UserNameBasedRateLimiterTest.java @@ -18,7 +18,6 @@ package org.opensearch.security.auth.limiting; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.user.AuthCredentials; diff --git a/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java b/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java index 4072d94436..eec6256bb6 100644 --- a/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java +++ b/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java @@ -11,15 +11,15 @@ package org.opensearch.security.authtoken.jwt; +import java.util.Collections; + +import org.junit.Test; import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.util.AuthTokenUtils; import org.opensearch.test.rest.FakeRestRequest; -import org.junit.Test; - -import java.util.Collections; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtilsTest.java b/src/test/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtilsTest.java index 4890f380f9..df6456303a 100644 --- a/src/test/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtilsTest.java +++ b/src/test/java/org/opensearch/security/authtoken/jwt/EncryptionDecryptionUtilsTest.java @@ -11,9 +11,10 @@ package org.opensearch.security.authtoken.jwt; +import java.util.Base64; + import org.junit.Assert; import org.junit.Test; -import java.util.Base64; public class EncryptionDecryptionUtilsTest { diff --git a/src/test/java/org/opensearch/security/authtoken/jwt/JwtVendorTest.java b/src/test/java/org/opensearch/security/authtoken/jwt/JwtVendorTest.java index 9c51dd714b..094e61eae3 100644 --- a/src/test/java/org/opensearch/security/authtoken/jwt/JwtVendorTest.java +++ b/src/test/java/org/opensearch/security/authtoken/jwt/JwtVendorTest.java @@ -17,8 +17,6 @@ import java.util.Optional; import java.util.function.LongSupplier; -import com.google.common.io.BaseEncoding; -import com.nimbusds.jwt.SignedJWT; import org.apache.commons.lang3.RandomStringUtils; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -27,7 +25,7 @@ import org.apache.logging.log4j.core.Logger; import org.junit.Assert; import org.junit.Test; -import org.mockito.ArgumentCaptor; +import com.google.common.io.BaseEncoding; import org.opensearch.OpenSearchException; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; @@ -35,6 +33,8 @@ import com.nimbusds.jose.JWSSigner; import com.nimbusds.jose.jwk.JWK; +import com.nimbusds.jwt.SignedJWT; +import org.mockito.ArgumentCaptor; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -42,9 +42,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; - import static org.hamcrest.core.IsNull.notNullValue; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtilTest.java b/src/test/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtilTest.java index 78bd950964..2633c75c2f 100644 --- a/src/test/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtilTest.java +++ b/src/test/java/org/opensearch/security/authtoken/jwt/KeyPaddingUtilTest.java @@ -11,9 +11,10 @@ package org.opensearch.security.authtoken.jwt; -import com.nimbusds.jose.JWSAlgorithm; import org.junit.Test; +import com.nimbusds.jose.JWSAlgorithm; + import static org.junit.jupiter.api.Assertions.assertEquals; public class KeyPaddingUtilTest { diff --git a/src/test/java/org/opensearch/security/cache/CachingTest.java b/src/test/java/org/opensearch/security/cache/CachingTest.java index 39f0e1315d..9a6c0e14bb 100644 --- a/src/test/java/org/opensearch/security/cache/CachingTest.java +++ b/src/test/java/org/opensearch/security/cache/CachingTest.java @@ -16,7 +16,6 @@ import org.junit.Assert; import org.junit.Before; 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/ccstest/CrossClusterSearchTests.java b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java index e2dd28b563..b888dc643f 100644 --- a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java +++ b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java @@ -26,12 +26,11 @@ package org.opensearch.security.ccstest; -import com.google.common.collect.Lists; import org.apache.hc.core5.http.HttpStatus; import org.junit.After; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; diff --git a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java index ea329b7b2c..7c56cee649 100644 --- a/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java +++ b/src/test/java/org/opensearch/security/ccstest/RemoteReindexTests.java @@ -30,7 +30,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/configuration/SaltTest.java b/src/test/java/org/opensearch/security/configuration/SaltTest.java index 8af7501810..aba5f5e218 100644 --- a/src/test/java/org/opensearch/security/configuration/SaltTest.java +++ b/src/test/java/org/opensearch/security/configuration/SaltTest.java @@ -16,14 +16,13 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - 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 0edb14ce73..e83052d50c 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/AbstractDlsFlsTest.java @@ -16,7 +16,6 @@ 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; 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 d1b514a2e6..99400e72c2 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java @@ -19,15 +19,12 @@ import java.util.List; import java.util.function.Supplier; -import com.google.common.collect.Lists; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.IndicesRequest; import org.opensearch.action.IndicesRequest.Replaceable; @@ -44,11 +41,14 @@ import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; @@ -57,7 +57,6 @@ import org.opensearch.plugins.ActionPlugin; import org.opensearch.plugins.Plugin; import org.opensearch.repositories.RepositoriesService; -import org.opensearch.core.rest.RestStatus; import org.opensearch.script.ScriptService; import org.opensearch.security.OpenSearchSecurityPlugin; import org.opensearch.security.support.ConfigConstants; 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 3a03e8add4..205c210330 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedComplexMappingTest.java @@ -16,7 +16,6 @@ import org.apache.hc.core5.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; 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 672eb2abb0..29f6243197 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CustomFieldMaskedTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 43b78e9803..10d4be9939 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DateMathTest.java @@ -18,7 +18,6 @@ import org.apache.hc.core5.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; 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 580cabc66b..8c26f91fe9 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DfmOverwritesAllTest.java @@ -13,7 +13,6 @@ 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 bc349ace37..ead4f5442e 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsDateMathTest.java @@ -18,7 +18,6 @@ import org.apache.hc.core5.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; 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 6ac4690a70..06d93a95d0 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsFlsCrossClusterSearchTest.java @@ -15,7 +15,6 @@ import org.junit.After; 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/DlsNestedTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java index 67abf5f61b..47dc80cdac 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsNestedTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 5fe6419a02..5854977155 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsPropsReplaceTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 cc7b9e305d..8898420dc3 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsScrollTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 76112f533c..1db77b2f34 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermLookupQueryTest.java @@ -20,7 +20,6 @@ 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; 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 2f355f7b31..47e02571d3 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTermsLookupAsserts.java @@ -16,7 +16,6 @@ import java.util.Map; import org.junit.Assert; - import org.opensearch.search.SearchHit; import static org.junit.Assert.assertTrue; 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 587f759315..39ba684a5b 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 2628bebbc0..235f8e9d1a 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FieldMaskedTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 c486599ea4..c1def79fbd 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/Fls983Test.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 5e7584a1bc..fe135ab625 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestAB.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 a3776e567c..824bfe97b7 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestForbiddenField.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 e9d32f18ea..21839a1a9b 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsDlsTestMulti.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 bc3d306627..2d3d07ae34 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsExistsFieldsTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 a910cf5663..944823541e 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsTest.java @@ -16,7 +16,6 @@ import org.apache.hc.core5.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; 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 f6cfd036fd..eef517d251 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFieldsWcTest.java @@ -16,7 +16,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFlatTests.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFlatTests.java index 4d3e2d1846..32718bb2b4 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFlatTests.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsFlatTests.java @@ -11,6 +11,9 @@ package org.opensearch.security.dlic.dlsfls; +import java.util.function.BiFunction; +import java.util.function.Consumer; + import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Test; @@ -18,13 +21,11 @@ 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.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import org.opensearch.core.xcontent.XContentBuilder; -import java.util.function.BiFunction; -import java.util.function.Consumer; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsIndexingTests.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsIndexingTests.java index 2d7ed0efcf..d00f2e53bf 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsIndexingTests.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsIndexingTests.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; 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/FlsKeywordTests.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsKeywordTests.java index 1c51ec99b7..d6d3f955fb 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsKeywordTests.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsKeywordTests.java @@ -16,7 +16,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; 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/FlsPerfTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java index 32092cc8ed..6bb0a29720 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsPerfTest.java @@ -19,7 +19,6 @@ 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; 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 66c962051f..8e2fe020a0 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/FlsTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 75eb428ee8..a4caf74da5 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/IndexPatternTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; 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 6267aeb9c0..f77ccf30b3 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/MFlsTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/RenameFieldResponseProcessorTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/RenameFieldResponseProcessorTest.java index 28d9ed27ab..e86c094de4 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/RenameFieldResponseProcessorTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/RenameFieldResponseProcessorTest.java @@ -12,15 +12,13 @@ package org.opensearch.security.dlic.dlsfls; import org.apache.hc.core5.http.Header; -import org.opensearch.client.Client; - import org.apache.hc.core5.http.HttpStatus; import org.junit.Test; - import org.opensearch.action.index.IndexRequest; -import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.action.support.WriteRequest.RefreshPolicy; +import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.security.test.DynamicSecurityConfig; import org.opensearch.security.test.helper.cluster.ClusterConfiguration; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractApiActionValidationTest.java index b3d3dc0571..2fc39106b3 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AbstractApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AbstractApiActionValidationTest.java @@ -11,13 +11,15 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.List; +import java.util.Map; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; @@ -29,9 +31,8 @@ import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.threadpool.ThreadPool; -import java.io.IOException; -import java.util.List; -import java.util.Map; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; 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 f9c4428bc1..338a093727 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,7 +21,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; - import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditTestUtils; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiActionConfigValidationsTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiActionConfigValidationsTest.java index 99c6359b45..8da6ac49ff 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiActionConfigValidationsTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AccountApiActionConfigValidationsTest.java @@ -10,13 +10,14 @@ package org.opensearch.security.dlic.rest.api; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.junit.Test; -import org.mockito.Mockito; +import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.opensearch.core.rest.RestStatus; import org.opensearch.security.dlic.rest.support.Utils; import org.opensearch.security.securityconf.impl.v7.InternalUserV7; +import org.mockito.Mockito; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; 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 18e5cca8c7..8e6b1140b0 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 @@ -15,18 +15,17 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - 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.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; 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.PLUGINS_PREFIX; public class AccountApiTest extends AbstractRestApiUnitTest { private final String BASE_ENDPOINT; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiActionValidationTest.java index 82692b5fa3..88bc37c77e 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/ActionGroupsApiActionValidationTest.java @@ -11,11 +11,12 @@ import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; import org.opensearch.core.rest.RestStatus; import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.v7.ActionGroupsV7; +import org.mockito.Mockito; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; 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 46b730abac..8fd792d5e7 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 @@ -20,7 +20,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.DefaultObjectMapper; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AllowlistApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AllowlistApiTest.java index 27a1360a65..ba8dfb833e 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AllowlistApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AllowlistApiTest.java @@ -15,12 +15,11 @@ import java.util.stream.Collectors; import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.impl.AuditCategory; @@ -34,9 +33,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; /** * Testing class to verify that {@link AllowlistApiAction} works correctly. diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionRequestContentValidatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionRequestContentValidatorTest.java index 2629e41a8a..59eb1c4fe0 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionRequestContentValidatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionRequestContentValidatorTest.java @@ -11,6 +11,11 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import com.fasterxml.jackson.databind.InjectableValues; import org.junit.Test; import org.opensearch.common.settings.Settings; @@ -22,11 +27,6 @@ import org.opensearch.security.compliance.ComplianceConfig; import org.opensearch.security.util.FakeRestRequest; -import java.io.IOException; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; 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 8d431882da..fbb7b3ae5f 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 @@ -21,16 +21,15 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Streams; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Streams; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.AuditTestUtils; @@ -39,11 +38,11 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; -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.PLUGINS_PREFIX; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class AuditApiActionTest extends AbstractRestApiUnitTest { // admin cred with roles in test yml files diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionValidationTest.java index 7ffbda2fce..ffb4f71e24 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/AuditApiActionValidationTest.java @@ -11,6 +11,8 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; + import org.junit.Test; import org.opensearch.common.settings.Settings; import org.opensearch.core.rest.RestStatus; @@ -19,8 +21,6 @@ import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.util.FakeRestRequest; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; 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 46128f5a71..d0cbb7d759 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 @@ -14,7 +14,6 @@ import org.apache.hc.core5.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.test.helper.rest.RestHelper; 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 120596f046..6291dd8559 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,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; 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 09c4a762b5..31bc0b739b 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,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.DefaultObjectMapper; 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 aefb0f2550..9ba7058200 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,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.SecurityJsonNode; import org.opensearch.security.test.helper.file.FileHelper; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/InternalUsersApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/InternalUsersApiActionValidationTest.java index 853117b8b4..9f3883c8d5 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/InternalUsersApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/InternalUsersApiActionValidationTest.java @@ -11,11 +11,13 @@ package org.opensearch.security.dlic.rest.api; -import org.bouncycastle.crypto.generators.OpenBSDBCrypt; +import java.io.IOException; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; +import org.bouncycastle.crypto.generators.OpenBSDBCrypt; import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.RestRequest; import org.opensearch.security.DefaultObjectMapper; @@ -26,9 +28,8 @@ import org.opensearch.security.user.UserService; import org.opensearch.security.util.FakeRestRequest; -import java.io.IOException; -import java.util.List; -import java.util.Map; +import org.mockito.Mock; +import org.mockito.Mockito; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiTest.java index 7132dcc491..25b8efa326 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/MultiTenancyConfigApiTest.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; 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/rest/api/NodesDnApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/NodesDnApiTest.java index 0d052b3140..d64ff2fb19 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 @@ -18,12 +18,11 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.auditlog.impl.AuditCategory; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RequestHandlersBuilderTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RequestHandlersBuilderTest.java index 80a6c0115a..07355ab14b 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RequestHandlersBuilderTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RequestHandlersBuilderTest.java @@ -11,12 +11,11 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; +import java.util.stream.Collectors; + import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; import org.opensearch.client.Client; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.rest.RestStatus; @@ -26,8 +25,10 @@ import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.validation.ValidationResult; -import java.io.IOException; -import java.util.stream.Collectors; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; 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 bbe1bf90f8..8e13d7e45e 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 @@ -16,7 +16,6 @@ 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; 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 9d8badba6f..f4d64e6ad5 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 @@ -14,7 +14,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.DefaultObjectMapper; @@ -22,11 +21,10 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; +import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; public class RoleBasedAccessTest extends AbstractRestApiUnitTest { private final String ENDPOINT; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionRequestContentValidatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionRequestContentValidatorTest.java index cab192093c..5f7dc941fb 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionRequestContentValidatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionRequestContentValidatorTest.java @@ -11,13 +11,13 @@ package org.opensearch.security.dlic.rest.api; +import java.io.IOException; + import com.fasterxml.jackson.databind.node.ObjectNode; import org.junit.Test; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.security.util.FakeRestRequest; -import java.io.IOException; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionValidationTest.java index bff2056fa4..3e3a372814 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesApiActionValidationTest.java @@ -12,10 +12,11 @@ package org.opensearch.security.dlic.rest.api; import org.junit.Test; -import org.mockito.Mockito; import org.opensearch.core.rest.RestStatus; import org.opensearch.security.securityconf.impl.v7.RoleV7; +import org.mockito.Mockito; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; 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 1772bb0b67..6f1542dd54 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 @@ -11,6 +11,8 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -27,8 +29,6 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; -import java.util.List; - import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiActionValidationTest.java index 8c1b6b9285..5db4e5fde4 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/RolesMappingApiActionValidationTest.java @@ -11,14 +11,14 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.opensearch.core.rest.RestStatus; import org.opensearch.security.securityconf.impl.CType; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; 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 8d9b76274c..7b1e3d9416 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 @@ -20,7 +20,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.DefaultObjectMapper; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionTest.java index 7b98494e1b..00fd5c40d3 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionTest.java @@ -15,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.ConfigConstants; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionValidationTest.java index af80ad3a4d..25d315c220 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigApiActionValidationTest.java @@ -16,11 +16,11 @@ import org.opensearch.rest.RestRequest; import org.opensearch.security.util.FakeRestRequest; +import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; +import static org.opensearch.security.support.ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; -import static org.opensearch.security.support.ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION; public class SecurityConfigApiActionValidationTest extends AbstractApiActionValidationTest { diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigurationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigurationTest.java index 67858261a4..b60ad2fabf 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigurationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecurityConfigurationTest.java @@ -11,6 +11,8 @@ package org.opensearch.security.dlic.rest.api; +import java.util.List; + import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Before; import org.junit.Test; @@ -19,8 +21,6 @@ import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; import org.opensearch.security.securityconf.impl.v7.RoleV7; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; 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 d7a6edfea9..2edac837c3 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 @@ -14,7 +14,6 @@ import org.apache.hc.core5.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.test.helper.rest.RestHelper; 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 db27be85ee..74186b2db7 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 @@ -14,7 +14,6 @@ import org.apache.hc.core5.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.test.helper.rest.RestHelper; diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiActionValidationTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiActionValidationTest.java index 59fa37274b..833643d824 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiActionValidationTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SecuritySSLCertsApiActionValidationTest.java @@ -16,12 +16,12 @@ import org.opensearch.rest.RestRequest; import org.opensearch.security.util.FakeRestRequest; +import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.CERTS_INFO_ACTION; +import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.RELOAD_CERTS_ACTION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.CERTS_INFO_ACTION; -import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.RELOAD_CERTS_ACTION; public class SecuritySSLCertsApiActionValidationTest extends AbstractApiActionValidationTest { diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/SslCertsApiTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/SslCertsApiTest.java index 8797d196f5..0db1fb310a 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/SslCertsApiTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/SslCertsApiTest.java @@ -15,13 +15,12 @@ import java.util.Map; import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.support.ConfigConstants; 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 2c6a45faf7..99af827a1c 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 @@ -15,7 +15,6 @@ import org.apache.hc.core5.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.test.helper.rest.RestHelper; 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 678566c12b..84abf30461 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 @@ -26,7 +26,6 @@ import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; import org.opensearch.security.DefaultObjectMapper; @@ -37,6 +36,7 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper.HttpResponse; import org.opensearch.security.user.UserService; + import org.passay.CharacterCharacteristicsRule; import org.passay.CharacterRule; import org.passay.EnglishCharacterData; @@ -46,10 +46,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertNotEquals; import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; import static org.opensearch.security.dlic.rest.api.InternalUsersApiAction.RESTRICTED_FROM_USERNAME; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_ADMIN_ENABLED; +import static org.junit.Assert.assertNotEquals; public class UserApiTest extends AbstractRestApiUnitTest { private final String ENDPOINT; 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 398489b788..b352c59373 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 @@ -15,12 +15,11 @@ import java.util.stream.Collectors; import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.collect.ImmutableMap; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; import org.junit.Test; - +import com.google.common.collect.ImmutableMap; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.auditlog.impl.AuditCategory; @@ -34,9 +33,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX; /** * Testing class to verify that {@link WhitelistApiAction} works correctly. diff --git a/src/test/java/org/opensearch/security/dlic/rest/validation/EndpointValidatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/validation/EndpointValidatorTest.java index 8e3d6f5e70..ce0652f607 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/validation/EndpointValidatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/validation/EndpointValidatorTest.java @@ -11,13 +11,13 @@ package org.opensearch.security.dlic.rest.validation; +import java.io.IOException; +import java.util.List; + import org.apache.commons.lang3.tuple.Triple; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; import org.opensearch.core.rest.RestStatus; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.api.Endpoint; @@ -28,8 +28,9 @@ import org.opensearch.security.securityconf.impl.v7.ActionGroupsV7; import org.opensearch.security.securityconf.impl.v7.RoleV7; -import java.io.IOException; -import java.util.List; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/test/java/org/opensearch/security/dlic/rest/validation/PasswordValidatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/validation/PasswordValidatorTest.java index 22bdea982f..18212a149a 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/validation/PasswordValidatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/validation/PasswordValidatorTest.java @@ -13,15 +13,14 @@ import java.util.List; -import com.google.common.collect.ImmutableList; import org.junit.Test; - +import com.google.common.collect.ImmutableList; import org.opensearch.common.settings.Settings; -import static org.junit.Assert.assertEquals; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_MIN_LENGTH; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_SCORE_BASED_VALIDATION_STRENGTH; import static org.opensearch.security.support.ConfigConstants.SECURITY_RESTAPI_PASSWORD_VALIDATION_REGEX; +import static org.junit.Assert.assertEquals; public class PasswordValidatorTest { diff --git a/src/test/java/org/opensearch/security/dlic/rest/validation/RequestContentValidatorTest.java b/src/test/java/org/opensearch/security/dlic/rest/validation/RequestContentValidatorTest.java index 7f12dc2e72..7b9c411faf 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/validation/RequestContentValidatorTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/validation/RequestContentValidatorTest.java @@ -11,16 +11,19 @@ package org.opensearch.security.dlic.rest.validation; +import java.io.IOException; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.common.bytes.BytesArray; @@ -31,10 +34,8 @@ import org.opensearch.rest.RestRequest; import org.opensearch.security.DefaultObjectMapper; -import java.io.IOException; -import java.util.Collections; -import java.util.Map; -import java.util.Set; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/test/java/org/opensearch/security/filter/DelegatingRestHandlerTests.java b/src/test/java/org/opensearch/security/filter/DelegatingRestHandlerTests.java index 2afb285874..16ef9fdd4f 100644 --- a/src/test/java/org/opensearch/security/filter/DelegatingRestHandlerTests.java +++ b/src/test/java/org/opensearch/security/filter/DelegatingRestHandlerTests.java @@ -8,6 +8,12 @@ package org.opensearch.security.filter; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import org.junit.Test; import org.opensearch.client.node.NodeClient; import org.opensearch.core.common.bytes.BytesArray; @@ -17,12 +23,6 @@ import org.opensearch.rest.RestHandler; import org.opensearch.rest.RestRequest; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; diff --git a/src/test/java/org/opensearch/security/filter/RestPathMatchesTests.java b/src/test/java/org/opensearch/security/filter/RestPathMatchesTests.java index eed095c9b6..fd686bf857 100644 --- a/src/test/java/org/opensearch/security/filter/RestPathMatchesTests.java +++ b/src/test/java/org/opensearch/security/filter/RestPathMatchesTests.java @@ -8,12 +8,12 @@ package org.opensearch.security.filter; -import org.junit.Before; -import org.junit.Test; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import org.junit.Before; +import org.junit.Test; + import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; diff --git a/src/test/java/org/opensearch/security/filter/SecurityFilterTests.java b/src/test/java/org/opensearch/security/filter/SecurityFilterTests.java index 58a12a84a8..4a00682352 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityFilterTests.java +++ b/src/test/java/org/opensearch/security/filter/SecurityFilterTests.java @@ -14,17 +14,15 @@ 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 com.google.common.collect.ImmutableSet; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.core.action.ActionListener; -import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.security.auditlog.AuditLog; import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.configuration.CompatConfig; @@ -36,6 +34,8 @@ import org.opensearch.security.support.WildcardMatcher; import org.opensearch.threadpool.ThreadPool; +import org.mockito.ArgumentCaptor; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/opensearch/security/filter/SecurityRestFilterTests.java b/src/test/java/org/opensearch/security/filter/SecurityRestFilterTests.java index 5adcadb1f2..a26f962dea 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityRestFilterTests.java +++ b/src/test/java/org/opensearch/security/filter/SecurityRestFilterTests.java @@ -14,7 +14,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Test; - import org.opensearch.security.dlic.rest.api.AbstractRestApiUnitTest; import org.opensearch.security.securityconf.impl.AllowlistingSettings; import org.opensearch.security.securityconf.impl.WhitelistingSettings; diff --git a/src/test/java/org/opensearch/security/filter/SecurityRestFilterUnitTests.java b/src/test/java/org/opensearch/security/filter/SecurityRestFilterUnitTests.java index 1f3bca4705..d7ce9aa533 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityRestFilterUnitTests.java +++ b/src/test/java/org/opensearch/security/filter/SecurityRestFilterUnitTests.java @@ -11,6 +11,8 @@ package org.opensearch.security.filter; +import java.nio.file.Path; + import org.junit.Before; import org.junit.Test; import org.opensearch.client.node.NodeClient; @@ -30,8 +32,6 @@ import org.opensearch.security.ssl.transport.PrincipalExtractor; import org.opensearch.threadpool.ThreadPool; -import java.nio.file.Path; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/org/opensearch/security/filter/SecurityRestUtilsTests.java b/src/test/java/org/opensearch/security/filter/SecurityRestUtilsTests.java index 0424d780ef..b69636445e 100644 --- a/src/test/java/org/opensearch/security/filter/SecurityRestUtilsTests.java +++ b/src/test/java/org/opensearch/security/filter/SecurityRestUtilsTests.java @@ -1,11 +1,12 @@ package org.opensearch.security.filter; +import org.junit.Test; +import org.opensearch.http.netty4.Netty4HttpChannel; + import io.netty.handler.codec.http.DefaultFullHttpRequest; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpVersion; -import org.junit.Test; -import org.opensearch.http.netty4.Netty4HttpChannel; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/http/OnBehalfOfAuthenticatorTest.java b/src/test/java/org/opensearch/security/http/OnBehalfOfAuthenticatorTest.java index 9f2c5ad48a..8df5512b16 100644 --- a/src/test/java/org/opensearch/security/http/OnBehalfOfAuthenticatorTest.java +++ b/src/test/java/org/opensearch/security/http/OnBehalfOfAuthenticatorTest.java @@ -12,24 +12,18 @@ package org.opensearch.security.http; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.Base64; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.List; import java.util.HashSet; -import java.util.Arrays; +import java.util.List; +import java.util.Map; import java.util.Optional; - +import java.util.Set; import javax.crypto.SecretKey; -import com.google.common.io.BaseEncoding; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import io.jsonwebtoken.security.Keys; import org.apache.commons.lang3.RandomStringUtils; import org.apache.hc.core5.http.HttpHeaders; import org.apache.logging.log4j.Level; @@ -38,8 +32,7 @@ import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.Logger; import org.junit.Test; - -import org.mockito.ArgumentCaptor; +import com.google.common.io.BaseEncoding; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -49,7 +42,15 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.util.FakeRestRequest; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; +import org.mockito.ArgumentCaptor; + import static org.hamcrest.Matchers.equalTo; +import static org.opensearch.rest.RestRequest.Method.POST; +import static org.opensearch.rest.RestRequest.Method.PUT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -64,8 +65,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.opensearch.rest.RestRequest.Method.POST; -import static org.opensearch.rest.RestRequest.Method.PUT; public class OnBehalfOfAuthenticatorTest { final static String clusterName = "cluster_0"; 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 f7a2011a68..fa344d3289 100644 --- a/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java +++ b/src/test/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticatorTest.java @@ -31,22 +31,21 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.ImmutableSet; import org.junit.Before; import org.junit.Test; - +import com.google.common.collect.ImmutableSet; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.core.action.ActionListener; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.http.HttpChannel; import org.opensearch.http.HttpRequest; import org.opensearch.http.HttpResponse; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; -import org.opensearch.core.rest.RestStatus; import org.opensearch.security.filter.SecurityRequestChannel; import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.support.ConfigConstants; diff --git a/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java b/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java index 3da6ad3d7f..da8b10ff1c 100644 --- a/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java +++ b/src/test/java/org/opensearch/security/httpclient/HttpClientTest.java @@ -13,7 +13,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/identity/SecurityTokenManagerTest.java b/src/test/java/org/opensearch/security/identity/SecurityTokenManagerTest.java index bc3f3f9732..7d00fba26e 100644 --- a/src/test/java/org/opensearch/security/identity/SecurityTokenManagerTest.java +++ b/src/test/java/org/opensearch/security/identity/SecurityTokenManagerTest.java @@ -19,8 +19,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; import org.opensearch.OpenSearchSecurityException; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.service.ClusterService; @@ -38,16 +36,18 @@ import org.opensearch.security.user.UserService; import org.opensearch.threadpool.ThreadPool; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; - import static org.junit.Assert.assertThrows; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; 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 b66902f4b9..7cc79880ff 100644 --- a/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java +++ b/src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java @@ -18,7 +18,6 @@ import org.apache.hc.core5.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; diff --git a/src/test/java/org/opensearch/security/multitenancy/test/TenancyMultitenancyEnabledTests.java b/src/test/java/org/opensearch/security/multitenancy/test/TenancyMultitenancyEnabledTests.java index b25a50d934..f12db4c30b 100644 --- a/src/test/java/org/opensearch/security/multitenancy/test/TenancyMultitenancyEnabledTests.java +++ b/src/test/java/org/opensearch/security/multitenancy/test/TenancyMultitenancyEnabledTests.java @@ -15,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.message.BasicHeader; 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/multitenancy/test/TenancyPrivateTenantEnabledTests.java b/src/test/java/org/opensearch/security/multitenancy/test/TenancyPrivateTenantEnabledTests.java index 1af102802f..faf59ea636 100644 --- a/src/test/java/org/opensearch/security/multitenancy/test/TenancyPrivateTenantEnabledTests.java +++ b/src/test/java/org/opensearch/security/multitenancy/test/TenancyPrivateTenantEnabledTests.java @@ -15,7 +15,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.message.BasicHeader; 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/privileges/PrivilegesEvaluatorTest.java b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java index 4f25c71d66..c223e84b19 100644 --- a/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java +++ b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java @@ -16,7 +16,6 @@ import org.junit.Assert; import org.junit.Before; 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/privileges/PrivilegesEvaluatorUnitTest.java b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java index 811c817b65..04e58ae992 100644 --- a/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java +++ b/src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java @@ -8,17 +8,17 @@ package org.opensearch.security.privileges; -import com.google.common.collect.ImmutableList; -import org.junit.Test; - import java.util.List; +import org.junit.Test; +import com.google.common.collect.ImmutableList; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.opensearch.security.privileges.PrivilegesEvaluator.DNFOF_MATCHER; import static org.opensearch.security.privileges.PrivilegesEvaluator.isClusterPerm; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class PrivilegesEvaluatorUnitTest { diff --git a/src/test/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluatorTest.java b/src/test/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluatorTest.java index 2f6189bab2..e3a950d0df 100644 --- a/src/test/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluatorTest.java +++ b/src/test/java/org/opensearch/security/privileges/RestLayerPrivilegesEvaluatorTest.java @@ -23,9 +23,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.quality.Strictness; import org.opensearch.OpenSearchSecurityException; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; @@ -36,8 +33,12 @@ import org.opensearch.security.user.User; import org.opensearch.threadpool.ThreadPool; -import static org.hamcrest.Matchers.equalTo; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.quality.Strictness; + import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; diff --git a/src/test/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluatorTest.java b/src/test/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluatorTest.java index dc95a0dbe0..6c739ea8a1 100644 --- a/src/test/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluatorTest.java +++ b/src/test/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluatorTest.java @@ -11,14 +11,17 @@ package org.opensearch.security.privileges; -import com.google.common.collect.ImmutableSet; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Set; + import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - +import com.google.common.collect.ImmutableSet; import org.opensearch.action.ActionRequest; import org.opensearch.action.get.MultiGetRequest; import org.opensearch.action.search.SearchRequest; @@ -36,14 +39,12 @@ import org.opensearch.security.user.User; import org.opensearch.tasks.Task; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Set; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.opensearch.security.support.ConfigConstants.SYSTEM_INDEX_PERMISSION; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -52,7 +53,6 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import static org.opensearch.security.support.ConfigConstants.SYSTEM_INDEX_PERMISSION; @RunWith(MockitoJUnitRunner.class) public class SecurityIndexAccessEvaluatorTest { 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 3d37c132c9..9ab3be5195 100644 --- a/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java +++ b/src/test/java/org/opensearch/security/protected_indices/ProtectedIndicesTests.java @@ -33,7 +33,6 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.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; @@ -46,9 +45,9 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.core.rest.RestStatus; 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/sanity/tests/SecurityRestTestCase.java b/src/test/java/org/opensearch/security/sanity/tests/SecurityRestTestCase.java index 0511afc5da..ab8ff08d62 100644 --- a/src/test/java/org/opensearch/security/sanity/tests/SecurityRestTestCase.java +++ b/src/test/java/org/opensearch/security/sanity/tests/SecurityRestTestCase.java @@ -18,7 +18,6 @@ import java.util.Objects; import org.apache.hc.core5.http.HttpHost; - import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.client.RestClient; diff --git a/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsTest.java b/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsTest.java index 9d104381a6..ee37bbfac6 100644 --- a/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsTest.java +++ b/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsTest.java @@ -37,12 +37,10 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import org.junit.Assert; import org.junit.Test; -import org.mockito.Mockito; - +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.opensearch.common.settings.Settings; import org.opensearch.security.DefaultObjectMapper; import org.opensearch.security.dlic.rest.api.Endpoint; @@ -50,6 +48,8 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; +import org.mockito.Mockito; + import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.CERTS_INFO_ACTION; import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.ENDPOINTS_WITH_PERMISSIONS; import static org.opensearch.security.dlic.rest.api.RestApiAdminPrivilegesEvaluator.RELOAD_CERTS_ACTION; diff --git a/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsV6Test.java b/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsV6Test.java index edf5a7533b..0326e1fb1f 100644 --- a/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsV6Test.java +++ b/src/test/java/org/opensearch/security/securityconf/SecurityRolesPermissionsV6Test.java @@ -11,14 +11,19 @@ package org.opensearch.security.securityconf; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import org.junit.Assert; import org.junit.Test; -import org.mockito.quality.Strictness; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexAbstraction; @@ -33,11 +38,7 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import org.mockito.quality.Strictness; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; 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 f9febb3bda..339e5b4764 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 @@ -12,12 +12,11 @@ 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; import org.junit.runners.Parameterized; - +import com.google.common.collect.ImmutableList; import org.opensearch.security.DefaultObjectMapper; @RunWith(Parameterized.class) 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 07d446074c..120cc8cdf7 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 @@ -12,12 +12,11 @@ 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; import org.junit.runners.Parameterized; - +import com.google.common.collect.ImmutableList; import org.opensearch.security.DefaultObjectMapper; @RunWith(Parameterized.class) diff --git a/src/test/java/org/opensearch/security/securityconf/impl/v7/IndexPatternTests.java b/src/test/java/org/opensearch/security/securityconf/impl/v7/IndexPatternTests.java index 2b95a6e84c..f74db1875d 100644 --- a/src/test/java/org/opensearch/security/securityconf/impl/v7/IndexPatternTests.java +++ b/src/test/java/org/opensearch/security/securityconf/impl/v7/IndexPatternTests.java @@ -15,15 +15,11 @@ import java.util.Set; import java.util.TreeMap; -import com.google.common.collect.ImmutableSet; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.quality.Strictness; - +import com.google.common.collect.ImmutableSet; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexAbstraction; @@ -34,6 +30,10 @@ import org.opensearch.security.securityconf.ConfigModelV7.IndexPattern; import org.opensearch.security.user.User; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.quality.Strictness; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertThrows; diff --git a/src/test/java/org/opensearch/security/setting/DeprecatedSettingsTest.java b/src/test/java/org/opensearch/security/setting/DeprecatedSettingsTest.java index 143efe9b11..e704e58b27 100644 --- a/src/test/java/org/opensearch/security/setting/DeprecatedSettingsTest.java +++ b/src/test/java/org/opensearch/security/setting/DeprecatedSettingsTest.java @@ -9,19 +9,19 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; @RunWith(MockitoJUnitRunner.class) public class DeprecatedSettingsTest { diff --git a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java index ce614a17ca..475c1e8568 100644 --- a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java +++ b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java @@ -34,7 +34,6 @@ 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; diff --git a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java index 3568cf738b..279bf0bf87 100644 --- a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java @@ -21,16 +21,13 @@ import java.util.Random; import java.util.Set; -import com.google.common.collect.Lists; -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 com.google.common.collect.Lists; 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; @@ -46,6 +43,9 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.transport.Netty4ModulePlugin; +import io.netty.handler.ssl.OpenSsl; +import io.netty.util.internal.PlatformDependent; + public class OpenSSLTest extends SSLTest { private static final String USE_NETTY_DEFAULT_ALLOCATOR_PROPERTY = "opensearch.unsafe.use_netty_default_allocator"; private static String 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 5272af5781..507286d262 100644 --- a/src/test/java/org/opensearch/security/ssl/SSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/SSLTest.java @@ -24,14 +24,11 @@ import java.util.Arrays; import java.util.List; import java.util.Random; - import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; -import com.google.common.collect.Lists; -import io.netty.util.internal.PlatformDependent; import org.apache.hc.core5.http.NoHttpResponseException; import org.apache.lucene.util.Constants; import org.junit.Assert; @@ -39,7 +36,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - +import com.google.common.collect.Lists; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; @@ -64,6 +61,8 @@ import org.opensearch.security.test.helper.rest.RestHelper; import org.opensearch.transport.Netty4ModulePlugin; +import io.netty.util.internal.PlatformDependent; + import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_KEYSTORE_KEYPASSWORD; import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_HTTP_PEMKEY_PASSWORD; import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_KEYSTORE_KEYPASSWORD; diff --git a/src/test/java/org/opensearch/security/ssl/SecureSSLSettingsTest.java b/src/test/java/org/opensearch/security/ssl/SecureSSLSettingsTest.java index beb170a31a..77ea44d27d 100644 --- a/src/test/java/org/opensearch/security/ssl/SecureSSLSettingsTest.java +++ b/src/test/java/org/opensearch/security/ssl/SecureSSLSettingsTest.java @@ -6,7 +6,6 @@ import org.junit.Assert; import org.junit.Test; - import org.opensearch.common.settings.MockSecureSettings; import org.opensearch.common.settings.Settings; diff --git a/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java b/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java index 0376253b06..9bd2bf7cfd 100644 --- a/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java +++ b/src/test/java/org/opensearch/security/ssl/SecuritySSLReloadCertsActionTests.java @@ -11,6 +11,11 @@ package org.opensearch.security.ssl; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; + import com.fasterxml.jackson.databind.JsonNode; import org.junit.After; import org.junit.Assert; @@ -28,11 +33,6 @@ import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.rest.RestHelper; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; - public class SecuritySSLReloadCertsActionTests extends SingleClusterTest { private final ClusterConfiguration clusterConfiguration = ClusterConfiguration.DEFAULT; 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 79d53f4d7b..47a431f22c 100644 --- a/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java +++ b/src/test/java/org/opensearch/security/ssl/transport/DualModeSSLHandlerTests.java @@ -14,21 +14,21 @@ import java.util.ArrayList; import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opensearch.security.ssl.SecurityKeyStore; +import org.opensearch.security.ssl.util.SSLConnectionTestUtil; + import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.handler.ssl.SslHandler; -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; - import static org.opensearch.transport.NettyAllocator.getAllocator; public class DualModeSSLHandlerTests { 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 097d65472c..679651b2a4 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromFileTests.java @@ -15,7 +15,6 @@ import org.junit.Assert; import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; public class CertFromFileTests { 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 fb97fdcfd1..9a9e6b0154 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromKeystoreTests.java @@ -19,7 +19,6 @@ import org.junit.Assert; import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; public class CertFromKeystoreTests { 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 e4ab860759..606f5f476f 100644 --- a/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/CertFromTruststoreTests.java @@ -18,7 +18,6 @@ import org.junit.Assert; import org.junit.Test; - import org.opensearch.security.test.helper.file.FileHelper; public class CertFromTruststoreTests { 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 98ee95a90b..be9617b868 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 org.junit.Assert; import org.junit.Before; import org.junit.Test; + import org.mockito.ArgumentCaptor; import org.mockito.Mockito; diff --git a/src/test/java/org/opensearch/security/ssl/util/TLSUtilTests.java b/src/test/java/org/opensearch/security/ssl/util/TLSUtilTests.java index c77f05b39f..03d8b869ca 100644 --- a/src/test/java/org/opensearch/security/ssl/util/TLSUtilTests.java +++ b/src/test/java/org/opensearch/security/ssl/util/TLSUtilTests.java @@ -10,12 +10,13 @@ */ package org.opensearch.security.ssl.util; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; + import static org.opensearch.transport.NettyAllocator.getAllocator; public class TLSUtilTests { diff --git a/src/test/java/org/opensearch/security/support/Base64CustomHelperTest.java b/src/test/java/org/opensearch/security/support/Base64CustomHelperTest.java index e35e1d72ba..68cdd41cf7 100644 --- a/src/test/java/org/opensearch/security/support/Base64CustomHelperTest.java +++ b/src/test/java/org/opensearch/security/support/Base64CustomHelperTest.java @@ -11,10 +11,14 @@ package org.opensearch.security.support; -import com.amazon.dlic.auth.ldap.LdapUser; +import java.io.Serializable; +import java.net.InetSocketAddress; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.HashMap; + import org.junit.Assert; import org.junit.Test; -import org.ldaptive.LdapEntry; import org.opensearch.OpenSearchException; import org.opensearch.action.search.SearchRequest; import org.opensearch.core.common.io.stream.StreamOutput; @@ -23,11 +27,8 @@ import org.opensearch.security.user.AuthCredentials; import org.opensearch.security.user.User; -import java.io.Serializable; -import java.net.InetSocketAddress; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.HashMap; +import com.amazon.dlic.auth.ldap.LdapUser; +import org.ldaptive.LdapEntry; import static org.opensearch.security.support.Base64CustomHelper.deserializeObject; import static org.opensearch.security.support.Base64CustomHelper.serializeObject; diff --git a/src/test/java/org/opensearch/security/support/Base64JDKHelperTest.java b/src/test/java/org/opensearch/security/support/Base64JDKHelperTest.java index 341c4a8659..9b268d0ebf 100644 --- a/src/test/java/org/opensearch/security/support/Base64JDKHelperTest.java +++ b/src/test/java/org/opensearch/security/support/Base64JDKHelperTest.java @@ -11,10 +11,6 @@ package org.opensearch.security.support; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertThrows; -import static org.hamcrest.Matchers.containsString; - import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -24,7 +20,7 @@ import org.junit.Assert; import org.junit.Test; -import org.ldaptive.LdapEntry; +import com.google.common.io.BaseEncoding; import org.opensearch.OpenSearchException; import org.opensearch.action.search.SearchRequest; import org.opensearch.security.auth.UserInjector; @@ -32,7 +28,11 @@ import org.opensearch.security.user.User; import com.amazon.dlic.auth.ldap.LdapUser; -import com.google.common.io.BaseEncoding; +import org.ldaptive.LdapEntry; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertThrows; public class Base64JDKHelperTest { private static final class NotSafeSerializable implements Serializable { diff --git a/src/test/java/org/opensearch/security/support/GuardedSearchOperationWrapperTest.java b/src/test/java/org/opensearch/security/support/GuardedSearchOperationWrapperTest.java index 67090e9b3d..576eb1eae1 100644 --- a/src/test/java/org/opensearch/security/support/GuardedSearchOperationWrapperTest.java +++ b/src/test/java/org/opensearch/security/support/GuardedSearchOperationWrapperTest.java @@ -13,7 +13,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; - import org.opensearch.index.shard.SearchOperationListener; import org.opensearch.search.internal.ReaderContext; import org.opensearch.search.internal.SearchContext; diff --git a/src/test/java/org/opensearch/security/support/StreamableRegistryTest.java b/src/test/java/org/opensearch/security/support/StreamableRegistryTest.java index 13f2448b30..b36cbb5197 100644 --- a/src/test/java/org/opensearch/security/support/StreamableRegistryTest.java +++ b/src/test/java/org/opensearch/security/support/StreamableRegistryTest.java @@ -11,12 +11,12 @@ package org.opensearch.security.support; +import java.net.InetSocketAddress; + import org.junit.Assert; import org.junit.Test; import org.opensearch.OpenSearchException; -import java.net.InetSocketAddress; - public class StreamableRegistryTest { StreamableRegistry streamableRegistry = StreamableRegistry.getInstance(); diff --git a/src/test/java/org/opensearch/security/system_indices/AbstractSystemIndicesTests.java b/src/test/java/org/opensearch/security/system_indices/AbstractSystemIndicesTests.java index 5dcc050a37..1f808e659a 100644 --- a/src/test/java/org/opensearch/security/system_indices/AbstractSystemIndicesTests.java +++ b/src/test/java/org/opensearch/security/system_indices/AbstractSystemIndicesTests.java @@ -15,7 +15,6 @@ import java.util.List; import org.apache.hc.core5.http.Header; - import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; @@ -28,14 +27,15 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.core.rest.RestStatus; 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 org.junit.Assert.assertEquals; /** diff --git a/src/test/java/org/opensearch/security/system_indices/SystemIndexDisabledTests.java b/src/test/java/org/opensearch/security/system_indices/SystemIndexDisabledTests.java index e85bddecb4..0e35cd4142 100644 --- a/src/test/java/org/opensearch/security/system_indices/SystemIndexDisabledTests.java +++ b/src/test/java/org/opensearch/security/system_indices/SystemIndexDisabledTests.java @@ -11,6 +11,8 @@ package org.opensearch.security.system_indices; +import java.io.IOException; + import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Before; @@ -20,8 +22,6 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.security.test.helper.rest.RestHelper; -import java.io.IOException; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/opensearch/security/system_indices/SystemIndexPermissionDisabledTests.java b/src/test/java/org/opensearch/security/system_indices/SystemIndexPermissionDisabledTests.java index c3feb70b98..57efff47ad 100644 --- a/src/test/java/org/opensearch/security/system_indices/SystemIndexPermissionDisabledTests.java +++ b/src/test/java/org/opensearch/security/system_indices/SystemIndexPermissionDisabledTests.java @@ -11,6 +11,8 @@ package org.opensearch.security.system_indices; +import java.io.IOException; + import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpStatus; import org.junit.Before; @@ -20,8 +22,6 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.security.test.helper.rest.RestHelper; -import java.io.IOException; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java index 6ca6c65d91..b2565585c1 100644 --- a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java +++ b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java @@ -36,16 +36,12 @@ import java.util.Objects; import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; - import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import com.carrotsearch.randomizedtesting.RandomizedTest; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import io.netty.handler.ssl.OpenSsl; import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder; import org.apache.hc.client5.http.nio.AsyncClientConnectionManager; import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder; @@ -66,7 +62,8 @@ import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; import org.junit.rules.TestWatcher; - +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; @@ -94,6 +91,8 @@ import org.opensearch.security.test.helper.rules.SecurityTestWatcher; import org.opensearch.threadpool.ThreadPool; +import io.netty.handler.ssl.OpenSsl; + /* * There are real thread leaks during test execution, not all threads are * properly waited on or interrupted. While this normally doesn't create test diff --git a/src/test/java/org/opensearch/security/test/SingleClusterTest.java b/src/test/java/org/opensearch/security/test/SingleClusterTest.java index 2839e1e283..20fe5f0c85 100644 --- a/src/test/java/org/opensearch/security/test/SingleClusterTest.java +++ b/src/test/java/org/opensearch/security/test/SingleClusterTest.java @@ -31,7 +31,6 @@ 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; 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 1454422c22..dc14e5dc9d 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 @@ -34,7 +34,6 @@ import java.util.stream.Collectors; import com.google.common.collect.Lists; - import org.opensearch.index.reindex.ReindexModulePlugin; import org.opensearch.join.ParentJoinModulePlugin; import org.opensearch.percolator.PercolatorModulePlugin; 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 f3bfc1c110..fc91057b46 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 @@ -47,7 +47,6 @@ 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; @@ -59,9 +58,9 @@ import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.cluster.node.DiscoveryNodeRole; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.http.HttpInfo; import org.opensearch.node.Node; import org.opensearch.node.PluginAwareNode; 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 d243e3c10c..5e3cefc881 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 @@ -46,11 +46,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.Streams; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; diff --git a/src/test/java/org/opensearch/security/test/helper/network/SocketUtils.java b/src/test/java/org/opensearch/security/test/helper/network/SocketUtils.java index b9f014960c..c1758510a0 100644 --- a/src/test/java/org/opensearch/security/test/helper/network/SocketUtils.java +++ b/src/test/java/org/opensearch/security/test/helper/network/SocketUtils.java @@ -48,7 +48,6 @@ import java.util.Random; import java.util.SortedSet; import java.util.TreeSet; - import javax.net.ServerSocketFactory; /** 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 03a5d5ca16..fec7ac5200 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 @@ -38,7 +38,6 @@ import java.util.concurrent.CompletionException; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; @@ -86,7 +85,6 @@ import org.apache.hc.core5.util.Timeout; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.security.DefaultObjectMapper; 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/transport/SecurityInterceptorTests.java b/src/test/java/org/opensearch/security/transport/SecurityInterceptorTests.java index ea97a5897a..967e3862b5 100644 --- a/src/test/java/org/opensearch/security/transport/SecurityInterceptorTests.java +++ b/src/test/java/org/opensearch/security/transport/SecurityInterceptorTests.java @@ -9,17 +9,19 @@ package org.opensearch.security.transport; // CS-SUPPRESS-SINGLE: RegexpSingleline Extensions manager used for creating a mock +import java.net.InetAddress; import java.net.UnknownHostException; + import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.opensearch.Version; import org.opensearch.action.search.PitService; 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.core.common.transport.TransportAddress; +import org.opensearch.core.transport.TransportResponse; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.indices.IndicesService; import org.opensearch.repositories.RepositoriesService; @@ -40,18 +42,16 @@ import org.opensearch.transport.TransportInterceptor.AsyncSender; import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportRequestOptions; -import org.opensearch.core.common.transport.TransportAddress; -import org.opensearch.core.transport.TransportResponse; import org.opensearch.transport.TransportResponseHandler; import org.opensearch.transport.TransportService; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + import static java.util.Collections.emptySet; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -// CS-ENFORCE-SINGLE - -import java.net.InetAddress; public class SecurityInterceptorTests { diff --git a/src/test/java/org/opensearch/security/transport/SecuritySSLRequestHandlerTests.java b/src/test/java/org/opensearch/security/transport/SecuritySSLRequestHandlerTests.java index c168d06839..a10c2b4e5d 100644 --- a/src/test/java/org/opensearch/security/transport/SecuritySSLRequestHandlerTests.java +++ b/src/test/java/org/opensearch/security/transport/SecuritySSLRequestHandlerTests.java @@ -12,8 +12,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.ArgumentMatchers; -import org.mockito.Mock; import org.opensearch.Version; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.SslExceptionHandler; @@ -27,6 +25,9 @@ import org.opensearch.transport.TransportRequest; import org.opensearch.transport.TransportRequestHandler; +import org.mockito.ArgumentMatchers; +import org.mockito.Mock; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doNothing; diff --git a/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorV4Test.java b/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorV4Test.java index 976f085ce4..044be021a2 100644 --- a/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorV4Test.java +++ b/src/test/java/org/opensearch/security/util/SettingsBasedSSLConfiguratorV4Test.java @@ -24,7 +24,6 @@ import java.security.KeyStore; import java.security.cert.Certificate; import java.util.Map; - import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; @@ -62,16 +61,15 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - -import com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4; -import com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4.SSLConfig; - import org.opensearch.common.settings.MockSecureSettings; 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 com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4; +import com.amazon.dlic.util.SettingsBasedSSLConfiguratorV4.SSLConfig; + import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.instanceOf; import static org.opensearch.security.ssl.SecureSSLSettings.SSLSetting.SECURITY_SSL_TRANSPORT_TRUSTSTORE_PASSWORD;