From 299483103deaefe1d10f27e67328cb168ac9c743 Mon Sep 17 00:00:00 2001 From: Dave Lago Date: Thu, 6 Jan 2022 11:18:37 -0500 Subject: [PATCH 1/4] Removed explicit dependency on log4j Signed-off-by: Dave Lago --- pom.xml | 34 ------------------- .../amazon/dlic/auth/ldap/srv/LdapServer.java | 6 ++-- .../security/auditlog/impl/TracingTests.java | 9 ----- 3 files changed, 3 insertions(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index e97fda246f..723190690a 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,6 @@ 2.0.25.Final 1.67 - 2.17.1 25.1-jre 1.3.1 2.11.2 @@ -161,10 +160,6 @@ jts com.vividsolutions - - log4j-api - org.apache.logging.log4j - spatial4j org.locationtech.spatial4j @@ -207,13 +202,6 @@ provided - - org.apache.logging.log4j - log4j-core - ${log4j.version} - provided - - com.fasterxml.jackson.core jackson-databind @@ -226,18 +214,6 @@ - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - - - org.apache.logging.log4j - log4j-api - - - - org.ldaptive ldaptive @@ -247,10 +223,6 @@ commons-cli commons-cli - - slf4j-api - org.slf4j - @@ -341,12 +313,6 @@ org.apache.kafka kafka-clients ${kafka.version} - - - slf4j-api - org.slf4j - - com.onelogin 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 5c8b073246..1f1c0e40b3 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 @@ -29,8 +29,8 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +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; @@ -48,7 +48,7 @@ import com.unboundid.util.ssl.TrustStoreTrustManager; final class LdapServer { - private final static Logger LOG = LoggerFactory.getLogger(LdapServer.class); + private final static Logger LOG = LogManager.getLogger(LdapServer.class); private static final int LOCK_TIMEOUT = 60; private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; 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 3da4237513..2e114c4b82 100644 --- a/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java +++ b/src/test/java/org/opensearch/security/auditlog/impl/TracingTests.java @@ -30,9 +30,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.core.Logger; import org.junit.Assert; import org.junit.Test; @@ -54,11 +51,6 @@ protected String getResourceFolder() { @Test public void testHTTPTrace() throws Exception { - - Logger logger = (Logger) LogManager.getLogger("opendistro_security_action_trace"); - final Level level = logger.getLevel(); - logger.setLevel(Level.TRACE); - final Settings settings = Settings.builder() .put(ConfigConstants.SECURITY_AUDIT_TYPE_DEFAULT, "debug") .put(ConfigConstants.OPENDISTRO_SECURITY_AUDIT_RESOLVE_BULK_REQUESTS, "true") @@ -228,7 +220,6 @@ public void testHTTPTrace() throws Exception { "}"; System.out.println(rh.executePostRequest("a/b/_delete_by_query", dbqBody, encodeBasicHeader("admin", "admin"))); - logger.setLevel(level); Thread.sleep(5000); } From 63915b551fac75e1453b29ed148e6f2ef50a8517 Mon Sep 17 00:00:00 2001 From: Dave Lago Date: Thu, 6 Jan 2022 11:23:05 -0500 Subject: [PATCH 2/4] Removed extra space Signed-off-by: Dave Lago --- src/test/java/com/amazon/dlic/auth/ldap/srv/LdapServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1f1c0e40b3..92e103e9cb 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 @@ -48,7 +48,7 @@ import com.unboundid.util.ssl.TrustStoreTrustManager; final class LdapServer { - private final static Logger LOG = LogManager.getLogger(LdapServer.class); + private final static Logger LOG = LogManager.getLogger(LdapServer.class); private static final int LOCK_TIMEOUT = 60; private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; From 482855f936618cba951ca6b6240f1d1c433ded9e Mon Sep 17 00:00:00 2001 From: Dave Lago Date: Thu, 6 Jan 2022 15:02:49 -0500 Subject: [PATCH 3/4] Replaced log4j with slf4j-api Signed-off-by: Dave Lago --- pom.xml | 17 ++++++++++ .../jwt/AbstractHTTPJwtAuthenticator.java | 8 ++--- .../auth/http/jwt/HTTPJwtAuthenticator.java | 6 ++-- ...TTPJwtKeyByOpenIdConnectAuthenticator.java | 2 +- .../auth/http/jwt/keybyoidc/JwtVerifier.java | 6 ++-- .../http/jwt/keybyoidc/KeySetRetriever.java | 6 ++-- .../jwt/keybyoidc/SelfRefreshingKeySet.java | 10 +++--- .../kerberos/HTTPSpnegoAuthenticator.java | 6 ++-- .../http/saml/AuthTokenProcessorHandler.java | 8 ++--- .../auth/http/saml/HTTPSamlAuthenticator.java | 6 ++-- .../auth/http/saml/Saml2SettingsProvider.java | 6 ++-- .../backend/LDAPAuthenticationBackend.java | 6 ++-- .../backend/LDAPAuthorizationBackend.java | 6 ++-- .../com/amazon/dlic/auth/ldap/util/Utils.java | 6 ++-- .../ldap2/LDAPAuthenticationBackend2.java | 6 ++-- .../auth/ldap2/LDAPAuthorizationBackend2.java | 6 ++-- .../ldap2/LDAPConnectionFactoryFactory.java | 6 ++-- .../dlic/auth/ldap2/LDAPUserSearcher.java | 6 ++-- .../util/SettingsBasedSSLConfigurator.java | 6 ++-- .../security/OpenSearchSecurityPlugin.java | 10 +++--- .../TransportConfigUpdateAction.java | 6 ++-- .../security/auditlog/config/AuditConfig.java | 2 +- .../auditlog/impl/AbstractAuditLog.java | 14 ++++----- .../auditlog/impl/RequestResolver.java | 8 ++--- .../auditlog/routing/AsyncStoragePool.java | 6 ++-- .../auditlog/routing/AuditMessageRouter.java | 6 ++-- .../security/auditlog/sink/AuditLogSink.java | 6 ++-- .../security/auditlog/sink/Log4JSink.java | 31 ++++++++++++++++--- .../security/auditlog/sink/SinkProvider.java | 6 ++-- .../security/auth/AuthenticationBackend.java | 2 +- .../security/auth/AuthorizationBackend.java | 2 +- .../security/auth/BackendRegistry.java | 6 ++-- .../security/auth/HTTPAuthenticator.java | 2 +- .../security/auth/RolesInjector.java | 6 ++-- .../security/auth/UserInjector.java | 6 ++-- .../HeapBasedClientBlockRegistry.java | 6 ++-- .../security/compliance/ComplianceConfig.java | 6 ++-- ...mplianceIndexingOperationListenerImpl.java | 6 ++-- .../compliance/FieldReadCallback.java | 6 ++-- .../security/configuration/AdminDNs.java | 6 ++-- .../configuration/ClusterInfoHolder.java | 6 ++-- .../security/configuration/CompatConfig.java | 6 ++-- .../ConfigurationLoaderSecurity7.java | 8 ++--- .../ConfigurationRepository.java | 6 ++-- .../configuration/DlsFlsValveImpl.java | 6 ++-- .../PrivilegesInterceptorImpl.java | 6 ++-- .../security/configuration/Salt.java | 6 ++-- .../SecurityIndexSearcherWrapper.java | 6 ++-- .../dlic/rest/api/AbstractApiAction.java | 6 ++-- .../dlic/rest/api/AccountApiAction.java | 2 +- .../dlic/rest/api/InternalUsersApiAction.java | 2 +- .../rest/api/PatchableResourceApiAction.java | 6 ++-- .../rest/api/RestApiPrivilegesEvaluator.java | 6 ++-- .../AbstractConfigurationValidator.java | 12 +++---- .../security/filter/SecurityFilter.java | 8 ++--- .../security/filter/SecurityRestFilter.java | 10 +++--- .../security/http/HTTPBasicAuthenticator.java | 6 ++-- .../http/HTTPClientCertAuthenticator.java | 6 ++-- .../security/http/HTTPProxyAuthenticator.java | 6 ++-- .../security/http/RemoteIpDetector.java | 6 ++-- .../opensearch/security/http/XFFResolver.java | 6 ++-- .../proxy/HTTPExtendedProxyAuthenticator.java | 6 ++-- .../security/httpclient/HttpClient.java | 6 ++-- .../security/privileges/DlsFlsEvaluator.java | 6 ++-- .../privileges/PrivilegesEvaluator.java | 6 ++-- .../ProtectedIndexAccessEvaluator.java | 6 ++-- .../SecurityIndexAccessEvaluator.java | 6 ++-- .../privileges/SnapshotRestoreEvaluator.java | 6 ++-- .../privileges/TermsAggregationEvaluator.java | 6 ++-- .../resolver/IndexResolverReplacer.java | 6 ++-- .../security/rest/DashboardsInfoAction.java | 8 ++--- .../security/rest/SecurityInfoAction.java | 6 ++-- .../security/rest/TenantInfoAction.java | 8 ++--- .../security/securityconf/ConfigModelV6.java | 10 +++--- .../security/securityconf/ConfigModelV7.java | 8 ++--- .../securityconf/DynamicConfigFactory.java | 6 ++-- .../securityconf/DynamicConfigModel.java | 6 ++-- .../setting/OpensearchDynamicSetting.java | 6 ++-- .../security/ssl/DefaultSecurityKeyStore.java | 6 ++-- .../ssl/OpenSearchSecuritySSLPlugin.java | 6 ++-- .../SecuritySSLNettyHttpServerTransport.java | 6 ++-- .../ssl/http/netty/ValidatingDispatcher.java | 6 ++-- .../ssl/rest/SecuritySSLCertsInfoAction.java | 6 ++-- .../ssl/rest/SecuritySSLInfoAction.java | 6 ++-- .../transport/DefaultPrincipalExtractor.java | 6 ++-- .../ssl/transport/DualModeSSLHandler.java | 6 ++-- .../security/ssl/transport/SSLConfig.java | 6 ++-- .../transport/SecuritySSLNettyTransport.java | 8 ++--- .../transport/SecuritySSLRequestHandler.java | 6 ++-- .../SecuritySSLTransportInterceptor.java | 6 ++-- .../ssl/util/SSLCertificateHelper.java | 6 ++-- .../ssl/util/SSLConnectionTestUtil.java | 6 ++-- .../security/ssl/util/SSLRequestHelper.java | 6 ++-- .../security/support/Base64Helper.java | 6 ++-- .../security/support/ConfigHelper.java | 6 ++-- .../security/support/HTTPHelper.java | 2 +- .../security/support/PemKeyReader.java | 6 ++-- .../security/support/ReflectionHelper.java | 6 ++-- .../security/support/SecurityUtils.java | 6 ++-- .../support/SnapshotRestoreHelper.java | 6 ++-- .../DefaultInterClusterRequestEvaluator.java | 6 ++-- .../transport/SecurityInterceptor.java | 6 ++-- .../transport/SecurityRequestHandler.java | 2 +- .../ratetracking/HeapBasedRateTracker.java | 6 ++-- .../amazon/dlic/auth/ldap/srv/LdapServer.java | 6 ++-- .../opensearch/security/ResolveAPITests.java | 6 ++-- .../security/RolesInjectorIntegTest.java | 2 +- .../TransportUserInjectorIntegTest.java | 2 +- .../ccstest/CrossClusterSearchTests.java | 4 +-- .../ssl/CertificateValidatorTest.java | 6 ++-- .../test/AbstractSecurityUnitTest.java | 6 ++-- .../test/helper/cluster/ClusterHelper.java | 6 ++-- .../security/test/helper/file/FileHelper.java | 6 ++-- .../security/test/helper/rest/RestHelper.java | 6 ++-- 114 files changed, 380 insertions(+), 342 deletions(-) diff --git a/pom.xml b/pom.xml index 723190690a..0eedf93edd 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,7 @@ 2.0.25.Final 1.67 + 1.7.32 25.1-jre 1.3.1 2.11.2 @@ -214,6 +215,12 @@ + + org.slf4j + slf4j-api + ${slf4j.version} + + org.ldaptive ldaptive @@ -223,6 +230,10 @@ commons-cli commons-cli + + slf4j-api + org.slf4j + @@ -313,6 +324,12 @@ org.apache.kafka kafka-clients ${kafka.version} + + + slf4j-api + org.slf4j + + com.onelogin 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 9613a2ade1..8ea4f3ba3f 100644 --- a/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java +++ b/src/main/java/com/amazon/dlic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java @@ -26,8 +26,8 @@ import org.apache.cxf.rs.security.jose.jwt.JwtClaims; import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.http.HttpHeaders; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.Strings; @@ -46,7 +46,7 @@ import org.opensearch.security.user.AuthCredentials; public abstract class AbstractHTTPJwtAuthenticator implements HTTPAuthenticator { - private final static Logger log = LogManager.getLogger(AbstractHTTPJwtAuthenticator.class); + private final static Logger log = LoggerFactory.getLogger(AbstractHTTPJwtAuthenticator.class); private static final String BEARER = "bearer "; private static final Pattern BASIC = Pattern.compile("^\\s*Basic\\s.*", Pattern.CASE_INSENSITIVE); @@ -108,7 +108,7 @@ private AuthCredentials extractCredentials0(final RestRequest request) throws Op try { jwt = jwtVerifier.getVerifiedJwtToken(jwtString); } catch (AuthenticatorUnavailableException e) { - log.info(e); + log.info(e.toString()); throw new OpenSearchSecurityException(e.getMessage(), RestStatus.SERVICE_UNAVAILABLE); } catch (BadCredentialsException e) { log.info("Extracting JWT token from {} failed", jwtString, e); 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 fbc18eb26b..da6a782374 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 @@ -29,8 +29,8 @@ import java.util.regex.Pattern; import org.apache.http.HttpHeaders; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -51,7 +51,7 @@ public class HTTPJwtAuthenticator implements HTTPAuthenticator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private static final Pattern BASIC = Pattern.compile("^\\s*Basic\\s.*", Pattern.CASE_INSENSITIVE); private static final String BEARER = "bearer "; diff --git a/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java b/src/main/java/com/amazon/dlic/auth/http/jwt/keybyoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java index 8c3c0ff18d..396667b943 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 @@ -24,7 +24,7 @@ public class HTTPJwtKeyByOpenIdConnectAuthenticator extends AbstractHTTPJwtAuthenticator { - //private final static Logger log = LogManager.getLogger(HTTPJwtKeyByOpenIdConnectAuthenticator.class); + //private final static Logger log = LoggerFactory.getLogger(HTTPJwtKeyByOpenIdConnectAuthenticator.class); public HTTPJwtKeyByOpenIdConnectAuthenticator(Settings settings, Path configPath) { super(settings, configPath); 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 ffb1e72e52..0de65fc2d7 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 @@ -27,14 +27,14 @@ import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.cxf.rs.security.jose.jwt.JwtUtils; import org.apache.commons.lang.StringEscapeUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import com.google.common.base.Strings; public class JwtVerifier { - private final static Logger log = LogManager.getLogger(JwtVerifier.class); + private final static Logger log = LoggerFactory.getLogger(JwtVerifier.class); private final KeyProvider keyProvider; 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 c81ec7e660..b675cc08d8 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 @@ -33,15 +33,15 @@ import org.apache.http.impl.client.cache.BasicHttpCacheStorage; import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClients; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import com.amazon.dlic.auth.http.jwt.oidc.json.OpenIdProviderConfiguration; import com.amazon.dlic.util.SettingsBasedSSLConfigurator.SSLConfig; public class KeySetRetriever implements KeySetProvider { - private final static Logger log = LogManager.getLogger(KeySetRetriever.class); + private final static Logger log = LoggerFactory.getLogger(KeySetRetriever.class); private static final long CACHE_STATUS_LOG_INTERVAL_MS = 60L * 60L * 1000L; private String openIdConnectEndpoint; 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 cd29b67bcf..1df68e6693 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 @@ -24,13 +24,13 @@ import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import com.google.common.base.Strings; public class SelfRefreshingKeySet implements KeyProvider { - private static final Logger log = LogManager.getLogger(SelfRefreshingKeySet.class); + private static final Logger log = LoggerFactory.getLogger(SelfRefreshingKeySet.class); private final KeySetProvider keySetProvider; private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 10, 1000, TimeUnit.MILLISECONDS, @@ -157,7 +157,7 @@ private synchronized JsonWebKey waitForRefreshToFinish(String kid) { wait(queuedThreadTimeoutMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - log.debug(e); + log.debug(e.toString()); } // Just be optimistic and re-check the key @@ -246,7 +246,7 @@ public void run() { wait(requestTimeoutMs); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - log.debug(e); + log.debug(e.toString()); } JsonWebKey result = getKeySimple(kid); 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 17caf578fc..590eabc067 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 @@ -33,8 +33,8 @@ import javax.security.auth.Subject; import javax.security.auth.login.LoginException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -65,7 +65,7 @@ public class HTTPSpnegoAuthenticator implements HTTPAuthenticator { private static final String EMPTY_STRING = ""; private static final Oid[] KRB_OIDS = new Oid[] {KrbConstants.SPNEGO, KrbConstants.KRB5MECH}; - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private boolean stripRealmFromPrincipalName; private Set acceptorPrincipal; 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 faa35697ca..30a1c5d6a9 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 @@ -40,8 +40,8 @@ import org.apache.cxf.rs.security.jose.jwt.JwtClaims; import org.apache.cxf.rs.security.jose.jwt.JwtToken; import org.apache.cxf.rs.security.jose.jwt.JwtUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.bytes.BytesReference; @@ -68,8 +68,8 @@ import com.onelogin.saml2.util.Util; class AuthTokenProcessorHandler { - private static final Logger log = LogManager.getLogger(AuthTokenProcessorHandler.class); - private static final Logger token_log = LogManager.getLogger("com.amazon.dlic.auth.http.saml.Token"); + private static final Logger log = LoggerFactory.getLogger(AuthTokenProcessorHandler.class); + private static final Logger token_log = LoggerFactory.getLogger("com.amazon.dlic.auth.http.saml.Token"); private static final Pattern EXPIRY_SETTINGS_PATTERN = Pattern.compile("\\s*(\\w+)\\s*(?:\\+\\s*(\\w+))?\\s*"); private Saml2SettingsProvider saml2SettingsProvider; 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 5d73f24c7a..222201c848 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 @@ -26,8 +26,8 @@ import net.shibboleth.utilities.java.support.xml.BasicParserPool; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.cxf.rs.security.jose.jwk.JsonWebKey; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -73,7 +73,7 @@ public class HTTPSamlAuthenticator implements HTTPAuthenticator, Destroyable { - protected final static Logger log = LogManager.getLogger(HTTPSamlAuthenticator.class); + protected final static Logger log = LoggerFactory.getLogger(HTTPSamlAuthenticator.class); public static final String IDP_METADATA_URL = "idp.metadata_url"; public static final String IDP_METADATA_FILE = "idp.metadata_file"; 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 2ffb234d8f..5cc3035fc9 100644 --- a/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java +++ b/src/main/java/com/amazon/dlic/auth/http/saml/Saml2SettingsProvider.java @@ -26,8 +26,8 @@ import java.util.Set; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -52,7 +52,7 @@ import net.shibboleth.utilities.java.support.resolver.ResolverException; public class Saml2SettingsProvider { - protected final static Logger log = LogManager.getLogger(Saml2SettingsProvider.class); + protected final static Logger log = LoggerFactory.getLogger(Saml2SettingsProvider.class); private final Settings opensearchSettings; private final MetadataResolver metadataResolver; 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 d6cbcb77f6..babb371357 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthenticationBackend.java @@ -27,8 +27,8 @@ import java.util.UUID; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; @@ -53,7 +53,7 @@ public class LDAPAuthenticationBackend implements AuthenticationBackend { static final String DEFAULT_USERBASE = ""; static final String DEFAULT_USERSEARCH_PATTERN = "(sAMAccountName={0})"; - protected static final Logger log = LogManager.getLogger(LDAPAuthenticationBackend.class); + protected static final Logger log = LoggerFactory.getLogger(LDAPAuthenticationBackend.class); private final Settings settings; private final Path configPath; 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 5ddc1f477c..278ba6e62a 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/backend/LDAPAuthorizationBackend.java @@ -43,8 +43,8 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.Strings; @@ -99,7 +99,7 @@ public class LDAPAuthorizationBackend implements AuthorizationBackend { static final String DEFAULT_ROLENAME = "name"; static final String DEFAULT_USERROLENAME = "memberOf"; - protected static final Logger log = LogManager.getLogger(LDAPAuthorizationBackend.class); + protected static final Logger log = LoggerFactory.getLogger(LDAPAuthorizationBackend.class); private final Settings settings; private final WildcardMatcher skipUsersMatcher; private final WildcardMatcher nestedRoleMatcher; 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 3e41e1f93d..0aa5d7429c 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java +++ b/src/main/java/com/amazon/dlic/auth/ldap/util/Utils.java @@ -25,8 +25,8 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; import org.ldaptive.Connection; @@ -34,7 +34,7 @@ public final class Utils { - private static final Logger log = LogManager.getLogger(Utils.class); + private static final Logger log = LoggerFactory.getLogger(Utils.class); private Utils() { 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 c00b665b21..4b6c767be7 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthenticationBackend2.java @@ -25,8 +25,8 @@ import java.util.Collections; import java.util.UUID; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -51,7 +51,7 @@ public class LDAPAuthenticationBackend2 implements AuthenticationBackend, Destroyable { - protected static final Logger log = LogManager.getLogger(LDAPAuthenticationBackend2.class); + protected static final Logger log = LoggerFactory.getLogger(LDAPAuthenticationBackend2.class); private final Settings settings; 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 393c610946..45990e7dae 100755 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPAuthorizationBackend2.java @@ -31,8 +31,8 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.SpecialPermission; import org.opensearch.common.Strings; @@ -68,7 +68,7 @@ public class LDAPAuthorizationBackend2 implements AuthorizationBackend, Destroya static final String DEFAULT_ROLENAME = "name"; static final String DEFAULT_USERROLENAME = "memberOf"; - protected static final Logger log = LogManager.getLogger(LDAPAuthorizationBackend2.class); + protected static final Logger log = LoggerFactory.getLogger(LDAPAuthorizationBackend2.class); private final Settings settings; private final WildcardMatcher skipUsersMatcher; private final WildcardMatcher nestedRoleMatcher; 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 b9114cf57a..78380ef386 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPConnectionFactoryFactory.java @@ -22,8 +22,8 @@ import java.util.List; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.ldaptive.ActivePassiveConnectionStrategy; import org.ldaptive.BindConnectionInitializer; @@ -67,7 +67,7 @@ public class LDAPConnectionFactoryFactory { - private static final Logger log = LogManager.getLogger(LDAPConnectionFactoryFactory.class); + private static final Logger log = LoggerFactory.getLogger(LDAPConnectionFactoryFactory.class); private final Settings settings; private final SettingsBasedSSLConfigurator.SSLConfig sslConfig; 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 10c4ee549b..51af76c3a3 100644 --- a/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java +++ b/src/main/java/com/amazon/dlic/auth/ldap2/LDAPUserSearcher.java @@ -23,8 +23,8 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.ldaptive.Connection; import org.ldaptive.LdapEntry; @@ -36,7 +36,7 @@ import com.amazon.dlic.auth.ldap.util.Utils; public class LDAPUserSearcher { - protected static final Logger log = LogManager.getLogger(LDAPUserSearcher.class); + protected static final Logger log = LoggerFactory.getLogger(LDAPUserSearcher.class); private static final int ZERO_PLACEHOLDER = 0; private static final String DEFAULT_USERBASE = ""; diff --git a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java index 25efdcb47b..22ff4e7773 100644 --- a/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java +++ b/src/main/java/com/amazon/dlic/util/SettingsBasedSSLConfigurator.java @@ -45,8 +45,8 @@ import org.apache.http.ssl.PrivateKeyStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.security.ssl.util.SSLConfigConstants; @@ -54,7 +54,7 @@ import com.google.common.collect.ImmutableList; public class SettingsBasedSSLConfigurator { - private static final Logger log = LogManager.getLogger(SettingsBasedSSLConfigurator.class); + private static final Logger log = LoggerFactory.getLogger(SettingsBasedSSLConfigurator.class); public static final String CERT_ALIAS = "cert_alias"; public static final String CA_ALIAS = "ca_alias"; diff --git a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java index 35fc237b35..6e42c73b05 100644 --- a/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java +++ b/src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java @@ -65,8 +65,8 @@ import org.opensearch.security.setting.OpensearchDynamicSetting; import org.opensearch.security.setting.TransportPassiveAuthSetting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.apache.lucene.search.QueryCachingPolicy; import org.apache.lucene.search.Weight; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -180,7 +180,7 @@ public final class OpenSearchSecurityPlugin extends OpenSearchSecuritySSLPlugin implements ClusterPlugin, MapperPlugin { private static final String KEYWORD = ".keyword"; - private static final Logger actionTrace = LogManager.getLogger("opendistro_security_action_trace"); + private static final Logger actionTrace = LoggerFactory.getLogger("opendistro_security_action_trace"); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(OpenSearchSecurityPlugin.class); public static final String LEGACY_OPENDISTRO_PREFIX = "_opendistro/_security"; @@ -321,7 +321,7 @@ public List run() { try (Stream s = Files.walk(confPath)) { return s.distinct().filter(p -> checkFilePermissions(p)).collect(Collectors.toList()); } catch (Exception e) { - log.error(e); + log.error(e.toString()); return null; } } @@ -351,7 +351,7 @@ public List run() { try (Stream s = Files.walk(confPath)) { return s.distinct().map(p -> sha256(p)).collect(Collectors.toList()); } catch (Exception e) { - log.error(e); + log.error(e.toString()); return null; } } 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 16240529db..d2d2407245 100644 --- a/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java +++ b/src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java @@ -33,8 +33,8 @@ import java.io.IOException; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.nodes.BaseNodeRequest; @@ -57,7 +57,7 @@ public class TransportConfigUpdateAction extends TransportNodesAction { - protected Logger logger = LogManager.getLogger(getClass()); + protected Logger logger = LoggerFactory.getLogger(getClass()); private final Provider backendRegistry; private final ConfigurationRepository configurationRepository; private DynamicConfigFactory dynamicConfigFactory; diff --git a/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java b/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java index 2f4aa7ece2..0ff0b26c5a 100644 --- a/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java +++ b/src/main/java/org/opensearch/security/auditlog/config/AuditConfig.java @@ -31,7 +31,7 @@ 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.slf4j.Logger; import org.opensearch.common.settings.Settings; import java.util.Collections; 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 0ca5be9e43..54bdfb9b50 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/AbstractAuditLog.java @@ -34,8 +34,8 @@ import org.opensearch.security.auditlog.config.AuditConfig; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.SpecialPermission; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkShardRequest; @@ -80,7 +80,7 @@ import static org.opensearch.common.xcontent.DeprecationHandler.THROW_UNSUPPORTED_OPERATION; public abstract class AbstractAuditLog implements AuditLog { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final ThreadPool threadPool; private final IndexNameExpressionResolver resolver; @@ -395,7 +395,7 @@ public void logDocumentRead(String index, String id, ShardId shardId, Map(XContentType.JSON, currentIndex.source()), id); } } catch (Exception e) { - log.error(e); + log.error(e.toString()); } //if we want to have msg.ComplianceWritePreviousSource we need to do the same as above 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 aca297b9f2..6b3c6882ee 100644 --- a/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java +++ b/src/main/java/org/opensearch/security/auditlog/impl/RequestResolver.java @@ -24,8 +24,8 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; @@ -65,7 +65,7 @@ public final class RequestResolver { - private static final Logger log = LogManager.getLogger(RequestResolver.class); + private static final Logger log = LoggerFactory.getLogger(RequestResolver.class); public static List resolve( final AuditCategory category, @@ -289,7 +289,7 @@ private static AuditMessage resolveInner(final AuditCategory category, builder.endObject(); msg.addUnescapedJsonToRequestBody(builder == null?null:Strings.toString(builder)); } catch (IOException e) { - log.error(e); + log.error(e.toString()); } finally { if(builder != null) { builder.close(); 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 04a4947d42..121feed858 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AsyncStoragePool.java @@ -21,14 +21,14 @@ import java.util.concurrent.TimeUnit; import org.opensearch.security.auditlog.config.ThreadPoolConfig; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.security.auditlog.impl.AuditMessage; import org.opensearch.security.auditlog.sink.AuditLogSink; public class AsyncStoragePool { - private static final Logger log = LogManager.getLogger(AsyncStoragePool.class); + private static final Logger log = LoggerFactory.getLogger(AsyncStoragePool.class); private final ExecutorService pool; private final ThreadPoolConfig threadPoolConfig; 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 cead468684..78ff768aed 100644 --- a/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java +++ b/src/main/java/org/opensearch/security/auditlog/routing/AuditMessageRouter.java @@ -24,8 +24,8 @@ import org.opensearch.security.auditlog.config.ThreadPoolConfig; 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 org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.threadpool.ThreadPool; @@ -41,7 +41,7 @@ public class AuditMessageRouter { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); final AuditLogSink defaultSink; volatile Map> categorySinks; final SinkProvider sinkProvider; 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 f3cfa5a045..d4401fb667 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/AuditLogSink.java @@ -19,8 +19,8 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -32,7 +32,7 @@ public abstract class AuditLogSink { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final Settings settings; protected final String settingsPrefix; private final String name; 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 41633a2399..04b4f94d91 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/Log4JSink.java @@ -16,8 +16,8 @@ package org.opensearch.security.auditlog.sink; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.security.auditlog.impl.AuditMessage; @@ -32,9 +32,9 @@ public final class Log4JSink extends AuditLogSink { public Log4JSink(final String name, final Settings settings, final String settingsPrefix, AuditLogSink fallbackSink) { super(name, settings, settingsPrefix, fallbackSink); loggerName = settings.get( settingsPrefix + ".log4j.logger_name","sgaudit"); - auditLogger = LogManager.getLogger(loggerName); + auditLogger = LoggerFactory.getLogger(loggerName); logLevel = Level.toLevel(settings.get(settingsPrefix + ".log4j.level","INFO").toUpperCase()); - enabled = auditLogger.isEnabled(logLevel); + enabled = isLogLevelEnabled(auditLogger, logLevel); } public boolean isHandlingBackpressure() { @@ -44,9 +44,30 @@ public boolean isHandlingBackpressure() { public boolean doStore(final AuditMessage msg) { if(enabled) { - auditLogger.log(logLevel, msg.toJson()); + logAtLevel(auditLogger, logLevel, msg.toJson()); } return true; } + private boolean isLogLevelEnabled(Logger logger, Level level) { + boolean isEnabled = false; + switch(level.toString()) { + case "TRACE": isEnabled = logger.isTraceEnabled(); + case "DEBUG": isEnabled = logger.isDebugEnabled(); + case "INFO": isEnabled = logger.isInfoEnabled(); + case "WARN": isEnabled = logger.isWarnEnabled(); + case "ERROR": isEnabled = logger.isErrorEnabled(); + } + return isEnabled; + } + + private void logAtLevel(Logger logger, Level level, String msg) { + switch(level.toString()) { + case "TRACE": logger.trace(msg); + case "DEBUG": logger.debug(msg); + case "INFO": logger.info(msg); + case "WARN": logger.warn(msg); + case "ERROR": logger.error(msg); + } + } } 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 f5a13a05da..f23a714a2e 100644 --- a/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java +++ b/src/main/java/org/opensearch/security/auditlog/sink/SinkProvider.java @@ -20,8 +20,8 @@ import java.util.Map; import java.util.Map.Entry; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.threadpool.ThreadPool; @@ -31,7 +31,7 @@ public class SinkProvider { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private static final String FALLBACKSINK_NAME = "fallback"; private static final String DEFAULTSINK_NAME = "default"; private final Client clientProvider; diff --git a/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java b/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java index 796b7579e2..4b66d782f0 100644 --- a/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java +++ b/src/main/java/org/opensearch/security/auth/AuthenticationBackend.java @@ -47,7 +47,7 @@ * The constructor should not throw any exception in case of an initialization problem. * Instead catch all exceptions and log a appropriate error message. A logger can be instantiated like: *

- * {@code private final Logger log = LogManager.getLogger(this.getClass());} + * {@code private final Logger log = LoggerFactory.getLogger(this.getClass());} * *

*/ diff --git a/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java b/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java index 286e73f938..361f5d8144 100644 --- a/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java +++ b/src/main/java/org/opensearch/security/auth/AuthorizationBackend.java @@ -47,7 +47,7 @@ * The constructor should not throw any exception in case of an initialization problem. * Instead catch all exceptions and log a appropriate error message. A logger can be instantiated like: *

- * {@code private final Logger log = LogManager.getLogger(this.getClass());} + * {@code private final Logger log = LoggerFactory.getLogger(this.getClass());} * *

*/ diff --git a/src/main/java/org/opensearch/security/auth/BackendRegistry.java b/src/main/java/org/opensearch/security/auth/BackendRegistry.java index ae712bc5ba..5e58c1ac9f 100644 --- a/src/main/java/org/opensearch/security/auth/BackendRegistry.java +++ b/src/main/java/org/opensearch/security/auth/BackendRegistry.java @@ -46,8 +46,8 @@ import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; @@ -81,7 +81,7 @@ public class BackendRegistry { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private SortedSet restAuthDomains; private Set restAuthorizers; private SortedSet transportAuthDomains; diff --git a/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java b/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java index b0bd5033ad..1433b8edbf 100644 --- a/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java +++ b/src/main/java/org/opensearch/security/auth/HTTPAuthenticator.java @@ -50,7 +50,7 @@ * The constructor should not throw any exception in case of an initialization problem. * Instead catch all exceptions and log a appropriate error message. A logger can be instantiated like: *

- * {@code private final Logger log = LogManager.getLogger(this.getClass());} + * {@code private final Logger log = LoggerFactory.getLogger(this.getClass());} *

*/ public interface HTTPAuthenticator { diff --git a/src/main/java/org/opensearch/security/auth/RolesInjector.java b/src/main/java/org/opensearch/security/auth/RolesInjector.java index 08263581d1..734a4547fa 100644 --- a/src/main/java/org/opensearch/security/auth/RolesInjector.java +++ b/src/main/java/org/opensearch/security/auth/RolesInjector.java @@ -20,8 +20,8 @@ import org.opensearch.security.user.User; import com.google.common.collect.ImmutableSet; import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportRequest; @@ -37,7 +37,7 @@ * User name is ignored. And roles are opendistro-roles. */ final public class RolesInjector { - protected final Logger log = LogManager.getLogger(RolesInjector.class); + protected final Logger log = LoggerFactory.getLogger(RolesInjector.class); private final AuditLog auditLog; public RolesInjector(AuditLog auditLog) { diff --git a/src/main/java/org/opensearch/security/auth/UserInjector.java b/src/main/java/org/opensearch/security/auth/UserInjector.java index 8fe5e7155d..e6ea690906 100644 --- a/src/main/java/org/opensearch/security/auth/UserInjector.java +++ b/src/main/java/org/opensearch/security/auth/UserInjector.java @@ -36,8 +36,8 @@ import java.util.Arrays; import java.util.Map; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.rest.RestRequest; @@ -52,7 +52,7 @@ public class UserInjector { - protected final Logger log = LogManager.getLogger(UserInjector.class); + protected final Logger log = LoggerFactory.getLogger(UserInjector.class); private final ThreadPool threadPool; private final AuditLog auditLog; 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 ba269fc4c8..3c612384f5 100644 --- a/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java +++ b/src/main/java/org/opensearch/security/auth/blocking/HeapBasedClientBlockRegistry.java @@ -19,8 +19,8 @@ import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -29,7 +29,7 @@ public class HeapBasedClientBlockRegistry implements ClientBlockRegistry { - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final Cache cache; private final Class clientIdType; diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java index 768bce3878..71023e5a5b 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceConfig.java @@ -47,8 +47,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.joda.time.DateTime; @@ -76,7 +76,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class ComplianceConfig { - private static final Logger log = LogManager.getLogger(ComplianceConfig.class); + private static final Logger log = LoggerFactory.getLogger(ComplianceConfig.class); public static final ComplianceConfig DEFAULT = ComplianceConfig.from(Settings.EMPTY); private static final int CACHE_SIZE = 1000; private static final String INTERNAL_OPENSEARCH = "internal_opensearch"; diff --git a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java index 84839421a4..cc5a6f45b0 100644 --- a/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java +++ b/src/main/java/org/opensearch/security/compliance/ComplianceIndexingOperationListenerImpl.java @@ -17,8 +17,8 @@ import java.util.Objects; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.index.IndexService; import org.opensearch.index.engine.Engine.Delete; @@ -33,7 +33,7 @@ public final class ComplianceIndexingOperationListenerImpl extends ComplianceIndexingOperationListener { - private static final Logger log = LogManager.getLogger(ComplianceIndexingOperationListenerImpl.class); + private static final Logger log = LoggerFactory.getLogger(ComplianceIndexingOperationListenerImpl.class); private final AuditLog auditlog; private volatile IndexService is; diff --git a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java index 38ec94665e..585d5c750f 100644 --- a/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java +++ b/src/main/java/org/opensearch/security/compliance/FieldReadCallback.java @@ -23,8 +23,8 @@ import java.util.Objects; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.apache.lucene.index.FieldInfo; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; @@ -49,7 +49,7 @@ public final class FieldReadCallback { - private static final Logger log = LogManager.getLogger(FieldReadCallback.class); + private static final Logger log = LoggerFactory.getLogger(FieldReadCallback.class); //private final ThreadContext threadContext; //private final ClusterService clusterService; private final Index index; diff --git a/src/main/java/org/opensearch/security/configuration/AdminDNs.java b/src/main/java/org/opensearch/security/configuration/AdminDNs.java index 20d27f2651..32c81193af 100644 --- a/src/main/java/org/opensearch/security/configuration/AdminDNs.java +++ b/src/main/java/org/opensearch/security/configuration/AdminDNs.java @@ -41,8 +41,8 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; @@ -53,7 +53,7 @@ public class AdminDNs { - protected final Logger log = LogManager.getLogger(AdminDNs.class); + protected final Logger log = LoggerFactory.getLogger(AdminDNs.class); private final Set adminDn = new HashSet(); private final Set adminUsernames = new HashSet(); private final Map allowedDnsImpersonations; diff --git a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java index 0721ee2b19..60d7b97c97 100644 --- a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java +++ b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java @@ -33,8 +33,8 @@ import java.util.Iterator; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.LegacyESVersion; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; @@ -46,7 +46,7 @@ public class ClusterInfoHolder implements ClusterStateListener { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private volatile Boolean has6xNodes = null; private volatile Boolean has6xIndices = null; private volatile DiscoveryNodes nodes = null; diff --git a/src/main/java/org/opensearch/security/configuration/CompatConfig.java b/src/main/java/org/opensearch/security/configuration/CompatConfig.java index 5b189a8e4e..77c442f76f 100644 --- a/src/main/java/org/opensearch/security/configuration/CompatConfig.java +++ b/src/main/java/org/opensearch/security/configuration/CompatConfig.java @@ -31,8 +31,8 @@ package org.opensearch.security.configuration; import org.opensearch.security.setting.OpensearchDynamicSetting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; import org.greenrobot.eventbus.Subscribe; @@ -44,7 +44,7 @@ public class CompatConfig { - private final Logger log = LogManager.getLogger(getClass()); + private final Logger log = LoggerFactory.getLogger(getClass()); private final Settings staticSettings; private DynamicConfigModel dcm; private final OpensearchDynamicSetting transportPassiveAuthSetting; diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java index b3abb18ca9..a04a508718 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java @@ -42,8 +42,8 @@ import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.support.ConfigHelper; import org.opensearch.security.support.SecurityUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.get.GetResponse; @@ -71,7 +71,7 @@ public class ConfigurationLoaderSecurity7 { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final Client client; private final String securityIndex; private final ClusterService cs; @@ -226,7 +226,7 @@ public void onResponse(MultiGetResponse response) { callback.failure(new Exception("Cannot parse settings for "+singleGetResponse.getId())); } } catch (Exception e) { - log.error(e.toString(),e); + log.error(e.toString()); callback.failure(e); } } else { diff --git a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java index 236a18afd1..4718d491db 100644 --- a/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java +++ b/src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java @@ -49,8 +49,8 @@ import org.opensearch.security.auditlog.config.AuditConfig; import org.opensearch.security.support.SecurityUtils; import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceAlreadyExistsException; @@ -80,7 +80,7 @@ import com.google.common.cache.CacheBuilder; public class ConfigurationRepository { - private static final Logger LOGGER = LogManager.getLogger(ConfigurationRepository.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationRepository.class); private final String securityIndex; private final Client client; diff --git a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java index 5474165ad0..f1fe1f36ed 100644 --- a/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java +++ b/src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java @@ -17,8 +17,8 @@ import org.opensearch.rest.RestStatus; import org.opensearch.security.support.SecurityUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.apache.lucene.util.BytesRef; import java.lang.reflect.Field; @@ -64,7 +64,7 @@ import com.google.common.collect.ImmutableList; public class DlsFlsValveImpl implements DlsFlsRequestValve { - private static final Logger log = LogManager.getLogger(DlsFlsValveImpl.class); + private static final Logger log = LoggerFactory.getLogger(DlsFlsValveImpl.class); /** * diff --git a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java index cac96fd492..8da3b4ad28 100644 --- a/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java +++ b/src/main/java/org/opensearch/security/configuration/PrivilegesInterceptorImpl.java @@ -18,8 +18,8 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; @@ -65,7 +65,7 @@ public class PrivilegesInterceptorImpl extends PrivilegesInterceptor { IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1" ); - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); public PrivilegesInterceptorImpl(IndexNameExpressionResolver resolver, ClusterService clusterService, Client client, ThreadPool threadPool) { super(resolver, clusterService, client, threadPool); diff --git a/src/main/java/org/opensearch/security/configuration/Salt.java b/src/main/java/org/opensearch/security/configuration/Salt.java index f9fc3ff8b3..f3aa563052 100644 --- a/src/main/java/org/opensearch/security/configuration/Salt.java +++ b/src/main/java/org/opensearch/security/configuration/Salt.java @@ -17,8 +17,8 @@ import org.opensearch.security.support.ConfigConstants; import com.google.common.annotations.VisibleForTesting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; @@ -31,7 +31,7 @@ */ public class Salt { - private static final Logger log = LogManager.getLogger(Salt.class); + private static final Logger log = LoggerFactory.getLogger(Salt.class); @VisibleForTesting static final int SALT_SIZE = 16; diff --git a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java index 4c313de2a0..9a2fa29f56 100644 --- a/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java +++ b/src/main/java/org/opensearch/security/configuration/SecurityIndexSearcherWrapper.java @@ -36,8 +36,8 @@ import org.opensearch.security.privileges.PrivilegesEvaluator; import org.opensearch.security.securityconf.ConfigModel; import org.opensearch.security.support.WildcardMatcher; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.apache.lucene.index.DirectoryReader; import org.opensearch.common.CheckedFunction; import org.opensearch.common.settings.Settings; @@ -53,7 +53,7 @@ public class SecurityIndexSearcherWrapper implements CheckedFunction { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final ThreadContext threadContext; protected final Index index; protected final String securityIndex; 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 a915495845..6d59f2adb4 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 @@ -22,8 +22,8 @@ import java.util.Objects; import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionListener; import org.opensearch.action.index.IndexRequest; @@ -72,7 +72,7 @@ public abstract class AbstractApiAction extends BaseRestHandler { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final ConfigurationRepository cl; protected final ClusterService cs; 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 8c7a4ec7ee..df264d138d 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 @@ -147,7 +147,7 @@ protected void handleGet(RestChannel channel, RestRequest request, Client client response = new BytesRestResponse(RestStatus.OK, builder); } catch (final Exception exception) { - log.error(exception.toString(), exception); + log.error(exception.toString()); builder.startObject() .field("error", exception.toString()) 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 871b80504c..f1754bbfde 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 @@ -194,7 +194,7 @@ protected AbstractConfigurationValidator postProcessApplyPatchResult(RestChannel builder.endObject(); retVal = getValidator(request, BytesReference.bytes(builder), resourceName); } catch (IOException e) { - log.error(e); + log.error(e.toString()); } ((ObjectNode) updatedResourceAsJsonNode).remove("password"); diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java index 2dd6e8c895..e2252d0524 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/PatchableResourceApiAction.java @@ -21,8 +21,8 @@ import java.util.Iterator; import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -53,7 +53,7 @@ public abstract class PatchableResourceApiAction extends AbstractApiAction { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); public PatchableResourceApiAction(Settings settings, Path configPath, RestController controller, Client client, AdminDNs adminDNs, ConfigurationRepository cl, ClusterService cs, 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 a7e37799fb..1556de4f83 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/RestApiPrivilegesEvaluator.java @@ -29,8 +29,8 @@ import java.util.Map.Entry; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.rest.RestRequest; @@ -47,7 +47,7 @@ // TODO: Make Singleton? public class RestApiPrivilegesEvaluator { - protected final Logger logger = LogManager.getLogger(this.getClass()); + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); private final AdminDNs adminDNs; private final PrivilegesEvaluator privilegesEvaluator; diff --git a/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java b/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java index 79adbbe76c..dbd45d675c 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java +++ b/src/main/java/org/opensearch/security/dlic/rest/validation/AbstractConfigurationValidator.java @@ -25,8 +25,8 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.DefaultObjectMapper; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -57,7 +57,7 @@ public abstract class AbstractConfigurationValidator { /* public for testing */ public final static String MISSING_MANDATORY_OR_KEYS_KEY = "specify_one_of"; - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); /** Define the various keys for this validator */ protected final Map allowedKeys = new HashMap<>(); @@ -135,7 +135,7 @@ public boolean validate() { } } catch (IOException e) { - log.error(ErrorType.BODY_NOT_PARSEABLE.toString(), e); + log.error(errorType.BODY_NOT_PARSEABLE.toString(), e); this.errorType = ErrorType.BODY_NOT_PARSEABLE; return false; } @@ -152,7 +152,7 @@ public boolean validate() { contentAsNode = DefaultObjectMapper.readTree(content.utf8ToString()); requested.addAll(ImmutableList.copyOf(contentAsNode.fieldNames())); } catch (Exception e) { - log.error(ErrorType.BODY_NOT_PARSEABLE.toString(), e); + log.error(errorType.BODY_NOT_PARSEABLE.toString(), e); this.errorType = ErrorType.BODY_NOT_PARSEABLE; return false; } @@ -183,7 +183,7 @@ public boolean validate() { return false; } } catch (Exception e) { - log.error(ErrorType.BODY_NOT_PARSEABLE.toString(), e); + log.error(errorType.BODY_NOT_PARSEABLE.toString(), e); this.errorType = ErrorType.BODY_NOT_PARSEABLE; return false; } diff --git a/src/main/java/org/opensearch/security/filter/SecurityFilter.java b/src/main/java/org/opensearch/security/filter/SecurityFilter.java index aa16dfac70..e2fd83bfc5 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityFilter.java @@ -41,8 +41,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; import org.opensearch.security.auth.BackendRegistry; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; @@ -104,7 +104,7 @@ public class SecurityFilter implements ActionFilter { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final PrivilegesEvaluator evalp; private final AdminDNs adminDns; private DlsFlsRequestValve dlsFlsValve; @@ -305,7 +305,7 @@ private void ap final PrivilegesEvaluatorResponse pres = eval.evaluate(user, action, request, task, injectedRoles); if (log.isDebugEnabled()) { - log.debug(pres); + log.debug(pres.toString()); } if (pres.isAllowed()) { diff --git a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java index e8b7abceda..800ac13a14 100644 --- a/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java +++ b/src/main/java/org/opensearch/security/filter/SecurityRestFilter.java @@ -37,8 +37,8 @@ import org.opensearch.security.configuration.AdminDNs; import org.opensearch.security.dlic.rest.api.WhitelistApiAction; import org.opensearch.security.securityconf.impl.WhitelistingSettings; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; @@ -71,7 +71,7 @@ public class SecurityRestFilter { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final BackendRegistry registry; private final AuditLog auditLog; private final ThreadContext threadContext; @@ -144,7 +144,7 @@ private boolean checkAndAuthenticateRequest(RestRequest request, RestChannel cha if(HTTPHelper.containsBadHeader(request)) { final OpenSearchException exception = ExceptionUtils.createBadHeaderException(); - log.error(exception); + log.error(exception.toString()); auditLog.logBadHeaders(request); channel.sendResponse(new BytesRestResponse(channel, RestStatus.FORBIDDEN, exception)); return true; @@ -152,7 +152,7 @@ private boolean checkAndAuthenticateRequest(RestRequest request, RestChannel cha if(SSLRequestHelper.containsBadHeader(threadContext, ConfigConstants.OPENDISTRO_SECURITY_CONFIG_PREFIX)) { final OpenSearchException exception = ExceptionUtils.createBadHeaderException(); - log.error(exception); + log.error(exception.toString()); auditLog.logBadHeaders(request); channel.sendResponse(new BytesRestResponse(channel, RestStatus.FORBIDDEN, exception)); return true; diff --git a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java index 0522f2fa15..1fbed7e647 100644 --- a/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPBasicAuthenticator.java @@ -32,8 +32,8 @@ import java.nio.file.Path; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.BytesRestResponse; @@ -48,7 +48,7 @@ //TODO FUTURE allow only if protocol==https public class HTTPBasicAuthenticator implements HTTPAuthenticator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); public HTTPBasicAuthenticator(final Settings settings, final Path configPath) { diff --git a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java index 2eb486d14a..d77a7f72e1 100644 --- a/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPClientCertAuthenticator.java @@ -39,8 +39,8 @@ import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -53,7 +53,7 @@ public class HTTPClientCertAuthenticator implements HTTPAuthenticator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final Settings settings; public HTTPClientCertAuthenticator(final Settings settings, final Path configPath) { diff --git a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java index 3389a2b72c..0ebeecb4e3 100644 --- a/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/HTTPProxyAuthenticator.java @@ -33,8 +33,8 @@ import java.nio.file.Path; import java.util.regex.Pattern; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; @@ -49,7 +49,7 @@ public class HTTPProxyAuthenticator implements HTTPAuthenticator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private volatile Settings settings; private final Pattern rolesSeparator; diff --git a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java index c6ce2107f3..45a60627bb 100644 --- a/src/main/java/org/opensearch/security/http/RemoteIpDetector.java +++ b/src/main/java/org/opensearch/security/http/RemoteIpDetector.java @@ -52,8 +52,8 @@ import java.util.List; import java.util.regex.Pattern; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.rest.RestRequest; @@ -69,7 +69,7 @@ final class RemoteIpDetector { /** * Logger */ - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); /** * Convert a given comma delimited String into an array of String diff --git a/src/main/java/org/opensearch/security/http/XFFResolver.java b/src/main/java/org/opensearch/security/http/XFFResolver.java index d29ff00a0f..537ceb7a30 100644 --- a/src/main/java/org/opensearch/security/http/XFFResolver.java +++ b/src/main/java/org/opensearch/security/http/XFFResolver.java @@ -32,8 +32,8 @@ import java.net.InetSocketAddress; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; @@ -46,7 +46,7 @@ public class XFFResolver { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private volatile boolean enabled; private volatile RemoteIpDetector detector; private final ThreadContext threadContext; 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 5ee8eff475..708c94ecda 100644 --- a/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/proxy/HTTPExtendedProxyAuthenticator.java @@ -34,8 +34,8 @@ import java.util.List; import java.util.Map.Entry; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -50,7 +50,7 @@ public class HTTPExtendedProxyAuthenticator extends HTTPProxyAuthenticator{ private static final String ATTR_PROXY = "attr.proxy."; private static final String ATTR_PROXY_USERNAME = "attr.proxy.username"; - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private volatile Settings settings; public HTTPExtendedProxyAuthenticator(Settings settings, final Path configPath) { diff --git a/src/main/java/org/opensearch/security/httpclient/HttpClient.java b/src/main/java/org/opensearch/security/httpclient/HttpClient.java index 90bb17b44d..9ef7ddc07f 100644 --- a/src/main/java/org/opensearch/security/httpclient/HttpClient.java +++ b/src/main/java/org/opensearch/security/httpclient/HttpClient.java @@ -46,8 +46,8 @@ import org.apache.http.ssl.PrivateKeyStrategy; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.support.WriteRequest.RefreshPolicy; @@ -129,7 +129,7 @@ public static HttpClientBuilder builder(final String... servers) { } private final KeyStore trustStore; - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private RestHighLevelClient rclient; private String basicCredentials; private KeyStore keystore; diff --git a/src/main/java/org/opensearch/security/privileges/DlsFlsEvaluator.java b/src/main/java/org/opensearch/security/privileges/DlsFlsEvaluator.java index 822c885949..6347a572dc 100644 --- a/src/main/java/org/opensearch/security/privileges/DlsFlsEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/DlsFlsEvaluator.java @@ -34,8 +34,8 @@ import java.util.Map; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; @@ -58,7 +58,7 @@ public class DlsFlsEvaluator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final ThreadPool threadPool; diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index d0d56328b5..4d8038b876 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -42,8 +42,8 @@ import java.util.regex.Pattern; import com.google.common.collect.ImmutableSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchSecurityException; import org.opensearch.action.ActionRequest; import org.opensearch.action.IndicesRequest; @@ -114,7 +114,7 @@ public class PrivilegesEvaluator { private static final IndicesOptions ALLOW_EMPTY = IndicesOptions.fromOptions(true, true, false, false); - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final ClusterService clusterService; private final IndexNameExpressionResolver resolver; diff --git a/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java index f1459078a2..dd6b6c0ee7 100644 --- a/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/ProtectedIndexAccessEvaluator.java @@ -23,8 +23,8 @@ import org.opensearch.security.securityconf.SecurityRoles; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.support.WildcardMatcher; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.ActionRequest; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.search.SearchRequest; @@ -33,7 +33,7 @@ public class ProtectedIndexAccessEvaluator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final AuditLog auditLog; private final WildcardMatcher indexMatcher; diff --git a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java index 83f52b0d67..d16b879040 100644 --- a/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SecurityIndexAccessEvaluator.java @@ -35,8 +35,8 @@ import java.util.List; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.ActionRequest; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.search.SearchRequest; @@ -51,7 +51,7 @@ public class SecurityIndexAccessEvaluator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final String securityIndex; private final AuditLog auditLog; diff --git a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java index c1a29babad..f7614d47d5 100644 --- a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java @@ -32,8 +32,8 @@ import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.common.settings.Settings; @@ -46,7 +46,7 @@ public class SnapshotRestoreEvaluator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final boolean enableSnapshotRestorePrivilege; private final String securityIndex; private final AuditLog auditLog; diff --git a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java index 6538562485..bb6524a0f7 100644 --- a/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/TermsAggregationEvaluator.java @@ -32,8 +32,8 @@ import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.ActionRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -50,7 +50,7 @@ public class TermsAggregationEvaluator { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private static final String[] READ_ACTIONS = new String[]{ "indices:data/read/msearch", diff --git a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java index f1c3d57588..bb8fdd2ab0 100644 --- a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java +++ b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java @@ -47,8 +47,8 @@ import org.opensearch.action.admin.indices.resolve.ResolveIndexAction; import org.opensearch.security.OpenSearchSecurityPlugin; import org.apache.commons.collections.keyvalue.MultiKey; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.ActionRequest; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.IndicesRequest; @@ -104,7 +104,7 @@ public class IndexResolverReplacer { private static final Set NULL_SET = new HashSet<>(Collections.singleton(null)); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final IndexNameExpressionResolver resolver; private final ClusterService clusterService; private final ClusterInfoHolder clusterInfoHolder; diff --git a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java index 5e90254aab..47df99195d 100644 --- a/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java @@ -36,8 +36,8 @@ import java.io.IOException; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -73,7 +73,7 @@ public class DashboardsInfoAction extends BaseRestHandler { "/_opendistro/_security")) .build(); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final PrivilegesEvaluator evaluator; private final ThreadContext threadContext; @@ -111,7 +111,7 @@ public void accept(RestChannel channel) throws Exception { response = new BytesRestResponse(RestStatus.OK, builder); } catch (final Exception e1) { - log.error(e1); + log.error(e1.toString()); builder = channel.newBuilder(); //NOSONAR builder.startObject(); builder.field("error", e1.toString()); diff --git a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java index 6a6bccb254..21e3e30fc8 100644 --- a/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/SecurityInfoAction.java @@ -40,8 +40,8 @@ import java.util.List; import java.util.Set; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.apache.lucene.util.RamUsageEstimator; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; @@ -69,7 +69,7 @@ public class SecurityInfoAction extends BaseRestHandler { new Route(POST, "/authinfo") ),"/_opendistro/_security", "/_plugins/_security"); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final PrivilegesEvaluator evaluator; private final ThreadContext threadContext; diff --git a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java index b00cdfe74b..7b908a4bd2 100644 --- a/src/main/java/org/opensearch/security/rest/TenantInfoAction.java +++ b/src/main/java/org/opensearch/security/rest/TenantInfoAction.java @@ -44,8 +44,8 @@ import org.opensearch.security.securityconf.impl.CType; import org.opensearch.security.securityconf.RoleMappings; import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.metadata.IndexAbstraction; import org.opensearch.cluster.service.ClusterService; @@ -75,7 +75,7 @@ public class TenantInfoAction extends BaseRestHandler { ), "/_opendistro/_security", "/_plugins/_security"); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final PrivilegesEvaluator evaluator; private final ThreadContext threadContext; private final ClusterService clusterService; @@ -131,7 +131,7 @@ public void accept(RestChannel channel) throws Exception { response = new BytesRestResponse(RestStatus.OK, builder); } } catch (final Exception e1) { - log.error(e1); + log.error(e1.toString()); builder = channel.newBuilder(); //NOSONAR builder.startObject(); builder.field("error", e1.toString()); diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java index 120cfc2e55..f975ed5891 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV6.java @@ -35,8 +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 org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -67,7 +67,7 @@ public class ConfigModelV6 extends ConfigModel { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private ConfigConstants.RolesMappingResolution rolesMappingResolution; private ActionGroupResolver agr = null; private SecurityRoles securityRoles = null; @@ -299,7 +299,7 @@ public SecurityRole call() throws Exception { public static class SecurityRoles implements org.opensearch.security.securityconf.SecurityRoles { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); final Set roles; @@ -937,7 +937,7 @@ private static String toQuotedCommaSeparatedString(final Set roles) { } private static final class IndexMatcherAndTypePermissions { - private static final Logger log = LogManager.getLogger(IndexMatcherAndTypePermissions.class); + private static final Logger log = LoggerFactory.getLogger(IndexMatcherAndTypePermissions.class); private final WildcardMatcher matcher; private final Set typePerms; diff --git a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java index 1eb2d8725e..612a8a2992 100644 --- a/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java +++ b/src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java @@ -35,8 +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 org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -67,7 +67,7 @@ public class ConfigModelV7 extends ConfigModel { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private ConfigConstants.RolesMappingResolution rolesMappingResolution; private ActionGroupResolver agr = null; private SecurityRoles securityRoles = null; @@ -285,7 +285,7 @@ public SecurityRole call() throws Exception { public static class SecurityRoles implements org.opensearch.security.securityconf.SecurityRoles { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); final Set roles; diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java index d607ed4189..b46b718794 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigFactory.java @@ -44,8 +44,8 @@ import org.opensearch.security.securityconf.impl.WhitelistingSettings; import org.opensearch.security.support.WildcardMatcher; import com.google.common.collect.ImmutableList; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.security.auth.internal.InternalAuthenticationBackend; @@ -120,7 +120,7 @@ public final static SecurityDynamicConfiguration addStatics(SecurityDynamicCo return original; } - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final ConfigurationRepository cr; private final AtomicBoolean initialized = new AtomicBoolean(); private final EventBus eventBus = EVENT_BUS_BUILDER.build(); diff --git a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java index c54903cda9..eb98d6e5c2 100644 --- a/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java +++ b/src/main/java/org/opensearch/security/securityconf/DynamicConfigModel.java @@ -38,8 +38,8 @@ import java.util.Set; import java.util.SortedSet; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.security.auth.AuthDomain; import org.opensearch.security.auth.AuthFailureListener; @@ -58,7 +58,7 @@ public abstract class DynamicConfigModel { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); public abstract SortedSet getRestAuthDomains(); public abstract Set getRestAuthorizers(); public abstract SortedSet getTransportAuthDomains(); diff --git a/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java b/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java index 9446829535..8eac0607b0 100644 --- a/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java +++ b/src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.java @@ -15,8 +15,8 @@ package org.opensearch.security.setting; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; @@ -30,7 +30,7 @@ public abstract class OpensearchDynamicSetting { private final Setting dynamicSetting; private volatile T dynamicSettingValue; - private final Logger logger = LogManager.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); public OpensearchDynamicSetting(Setting dynamicSetting, T dynamicSettingValue) { this.dynamicSetting = dynamicSetting; diff --git a/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java index 0b2456d4f9..6767c81b2d 100644 --- a/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java +++ b/src/main/java/org/opensearch/security/ssl/DefaultSecurityKeyStore.java @@ -66,8 +66,8 @@ import org.opensearch.security.ssl.util.SSLConfigConstants; import io.netty.util.internal.PlatformDependent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1ObjectIdentifier; @@ -100,7 +100,7 @@ private void printJCEWarnings() { } private final Settings settings; - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); public final SslProvider sslHTTPProvider; public final SslProvider sslTransportServerProvider; public final SslProvider sslTransportClientProvider; diff --git a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java index 554497422a..86e257d41c 100644 --- a/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java +++ b/src/main/java/org/opensearch/security/ssl/OpenSearchSecuritySSLPlugin.java @@ -39,8 +39,8 @@ import java.util.function.Function; import java.util.function.Supplier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.SpecialPermission; import org.opensearch.Version; @@ -92,7 +92,7 @@ public class OpenSearchSecuritySSLPlugin extends Plugin implements SystemIndexPl private static boolean USE_NETTY_DEFAULT_ALLOCATOR = Booleans.parseBoolean(System.getProperty("opensearch.unsafe.use_netty_default_allocator"), false); public static final boolean OPENSSL_SUPPORTED = (PlatformDependent.javaVersion() < 12) && USE_NETTY_DEFAULT_ALLOCATOR; - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected static final String CLIENT_TYPE = "client.type"; protected final boolean client; protected final boolean httpSSLEnabled; 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 2c5b51eb74..32171a79c1 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/SecuritySSLNettyHttpServerTransport.java @@ -17,8 +17,8 @@ package org.opensearch.security.ssl.http.netty; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; @@ -39,7 +39,7 @@ public class SecuritySSLNettyHttpServerTransport extends Netty4HttpServerTransport { - private static final Logger logger = LogManager.getLogger(SecuritySSLNettyHttpServerTransport.class); + private static final Logger logger = LoggerFactory.getLogger(SecuritySSLNettyHttpServerTransport.class); private final SecurityKeyStore sks; private final SslExceptionHandler errorHandler; 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 28bb9c1fa6..64a05aae09 100644 --- a/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java +++ b/src/main/java/org/opensearch/security/ssl/http/netty/ValidatingDispatcher.java @@ -21,8 +21,8 @@ import javax.net.ssl.SSLPeerUnverifiedException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchSecurityException; import org.opensearch.ExceptionsHelper; @@ -39,7 +39,7 @@ public class ValidatingDispatcher implements Dispatcher { - private static final Logger logger = LogManager.getLogger(ValidatingDispatcher.class); + private static final Logger logger = LoggerFactory.getLogger(ValidatingDispatcher.class); private final ThreadContext threadContext; private final Dispatcher originalDispatcher; diff --git a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java index cf87d60bf3..8913809fac 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLCertsInfoAction.java @@ -20,8 +20,8 @@ import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.user.User; import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -55,7 +55,7 @@ public class SecuritySSLCertsInfoAction extends BaseRestHandler { new Route(Method.GET, "/_opendistro/_security/api/ssl/certs") ); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private Settings settings; private SecurityKeyStore odsks; private AdminDNs adminDns; 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 e0a792f025..d45714e93f 100644 --- a/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java +++ b/src/main/java/org/opensearch/security/ssl/rest/SecuritySSLInfoAction.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; @@ -50,7 +50,7 @@ public class SecuritySSLInfoAction extends BaseRestHandler { new Route(Method.GET, "/_opendistro/_security/sslinfo") ); - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final SecurityKeyStore sks; final PrincipalExtractor principalExtractor; private final Path configPath; 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 b88a7e579b..563acbcee5 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DefaultPrincipalExtractor.java @@ -30,13 +30,13 @@ import javax.naming.ldap.Rdn; import javax.security.auth.x500.X500Principal; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.SpecialPermission; public class DefaultPrincipalExtractor implements PrincipalExtractor { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); @Override public String extractPrincipal(final X509Certificate x509Certificate, final Type type) { 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 8a57e14789..bb8e48e9b4 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/DualModeSSLHandler.java @@ -27,8 +27,8 @@ import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.ssl.SslHandler; import java.nio.charset.StandardCharsets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import javax.net.ssl.SSLException; import java.util.List; @@ -38,7 +38,7 @@ */ public class DualModeSSLHandler extends ByteToMessageDecoder { - private static final Logger logger = LogManager.getLogger(DualModeSSLHandler.class); + private static final Logger logger = LoggerFactory.getLogger(DualModeSSLHandler.class); private final SecurityKeyStore securityKeyStore; private final SslHandler providedSSLHandler; 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 a8ba381c84..8be854ebb8 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SSLConfig.java @@ -16,8 +16,8 @@ package org.opensearch.security.ssl.transport; import org.opensearch.security.support.ConfigConstants; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; @@ -25,7 +25,7 @@ public class SSLConfig { - private static final Logger logger = LogManager.getLogger(SSLConfig.class); + private static final Logger logger = LoggerFactory.getLogger(SSLConfig.class); private final boolean sslOnly; private volatile boolean dualModeEnabled; 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 842046eb5f..bb66e858e3 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLNettyTransport.java @@ -42,8 +42,8 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; @@ -71,7 +71,7 @@ public class SecuritySSLNettyTransport extends Netty4Transport { - private static final Logger logger = LogManager.getLogger(SecuritySSLNettyTransport.class); + private static final Logger logger = LoggerFactory.getLogger(SecuritySSLNettyTransport.class); private final SecurityKeyStore ossks; private final SslExceptionHandler errorHandler; private final SSLConfig SSLConfig; @@ -147,7 +147,7 @@ public final void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) th } protected static class ClientSSLHandler extends ChannelOutboundHandlerAdapter { - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final SecurityKeyStore sks; private final boolean hostnameVerificationEnabled; private final boolean hostnameVerificationResovleHostName; 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 9af76d1946..f1e82b1297 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLRequestHandler.java @@ -25,8 +25,8 @@ import javax.net.ssl.SSLPeerUnverifiedException; import org.opensearch.security.support.ConfigConstants; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.common.util.concurrent.ThreadContext; @@ -52,7 +52,7 @@ public class SecuritySSLRequestHandler private final String action; private final TransportRequestHandler actualHandler; private final ThreadPool threadPool; - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); private final PrincipalExtractor principalExtractor; private final SslExceptionHandler errorHandler; private final SSLConfig SSLConfig; 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 59df577f68..26dbd6b86a 100644 --- a/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java +++ b/src/main/java/org/opensearch/security/ssl/transport/SecuritySSLTransportInterceptor.java @@ -17,8 +17,8 @@ package org.opensearch.security.ssl.transport; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportInterceptor; @@ -29,7 +29,7 @@ public final class SecuritySSLTransportInterceptor implements TransportInterceptor { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final ThreadPool threadPool; protected final PrincipalExtractor principalExtractor; protected final SslExceptionHandler errorHandler; 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 f15cdc64f2..ce139de42b 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLCertificateHelper.java @@ -31,13 +31,13 @@ import java.util.Enumeration; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.Strings; public class SSLCertificateHelper { - private static final Logger log = LogManager.getLogger(SSLCertificateHelper.class); + private static final Logger log = LoggerFactory.getLogger(SSLCertificateHelper.class); private static boolean stripRootFromChain = true; //TODO check public static X509Certificate[] exportRootCertificates(final KeyStore ks, final String alias) throws KeyStoreException { 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 8df773b2f6..fa063f4b54 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLConnectionTestUtil.java @@ -23,8 +23,8 @@ import java.io.OutputStreamWriter; import java.net.Socket; import java.nio.charset.StandardCharsets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; /** * Utility class to test if the server supports SSL connections. @@ -34,7 +34,7 @@ */ public class SSLConnectionTestUtil { - private static final Logger logger = LogManager.getLogger(SSLConnectionTestUtil.class); + private static final Logger logger = LoggerFactory.getLogger(SSLConnectionTestUtil.class); public static final byte[] OPENSEARCH_PING_MSG = new byte[]{(byte) 'E', (byte) 'S', (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; public static final String DUAL_MODE_CLIENT_HELLO_MSG = "DUALCM"; public static final String DUAL_MODE_SERVER_HELLO_MSG = "DUALSM"; 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 9402c101a9..ad6f4391ef 100644 --- a/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java +++ b/src/main/java/org/opensearch/security/ssl/util/SSLRequestHelper.java @@ -38,8 +38,8 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; @@ -53,7 +53,7 @@ public class SSLRequestHelper { - private static final Logger log = LogManager.getLogger(SSLRequestHelper.class); + private static final Logger log = LoggerFactory.getLogger(SSLRequestHelper.class); public static class SSLInfo { private final X509Certificate[] x509Certs; diff --git a/src/main/java/org/opensearch/security/support/Base64Helper.java b/src/main/java/org/opensearch/security/support/Base64Helper.java index dbe255dd0e..07ceffdf2c 100644 --- a/src/main/java/org/opensearch/security/support/Base64Helper.java +++ b/src/main/java/org/opensearch/security/support/Base64Helper.java @@ -32,8 +32,8 @@ import com.amazon.dlic.auth.ldap.LdapUser; import org.apache.commons.lang3.SerializationUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.ldaptive.AbstractLdapBean; import org.ldaptive.LdapAttribute; import org.ldaptive.LdapEntry; @@ -76,7 +76,7 @@ import com.google.common.io.BaseEncoding; public class Base64Helper { - private static final Logger logger = LogManager.getLogger(Base64Helper.class); + private static final Logger logger = LoggerFactory.getLogger(Base64Helper.class); private static final String ODFE_PACKAGE = "com.amazon.opendistroforelasticsearch"; private static final String OS_PACKAGE = "org.opensearch"; diff --git a/src/main/java/org/opensearch/security/support/ConfigHelper.java b/src/main/java/org/opensearch/security/support/ConfigHelper.java index c3d88d4f2f..c0501f5ec3 100644 --- a/src/main/java/org/opensearch/security/support/ConfigHelper.java +++ b/src/main/java/org/opensearch/security/support/ConfigHelper.java @@ -37,8 +37,8 @@ import java.io.StringReader; import org.opensearch.security.securityconf.impl.Meta; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.DocWriteRequest.OpType; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; @@ -59,7 +59,7 @@ public class ConfigHelper { - private static final Logger LOGGER = LogManager.getLogger(ConfigHelper.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigHelper.class); public static void uploadFile(Client tc, String filepath, String index, CType cType, int configVersion) throws Exception { uploadFile(tc, filepath, index, cType, configVersion, false); diff --git a/src/main/java/org/opensearch/security/support/HTTPHelper.java b/src/main/java/org/opensearch/security/support/HTTPHelper.java index 0e08d86764..b2bc5e956d 100644 --- a/src/main/java/org/opensearch/security/support/HTTPHelper.java +++ b/src/main/java/org/opensearch/security/support/HTTPHelper.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Map; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; import org.opensearch.rest.RestRequest; import org.opensearch.security.user.AuthCredentials; diff --git a/src/main/java/org/opensearch/security/support/PemKeyReader.java b/src/main/java/org/opensearch/security/support/PemKeyReader.java index 22f2550744..ba72ed5a26 100644 --- a/src/main/java/org/opensearch/security/support/PemKeyReader.java +++ b/src/main/java/org/opensearch/security/support/PemKeyReader.java @@ -67,8 +67,8 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.bouncycastle.util.encoders.Base64; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; @@ -77,7 +77,7 @@ public final class PemKeyReader { //private static final String[] EMPTY_STRING_ARRAY = new String[0]; - protected static final Logger log = LogManager.getLogger(PemKeyReader.class); + protected static final Logger log = LoggerFactory.getLogger(PemKeyReader.class); static final String JKS = "JKS"; static final String PKCS12 = "PKCS12"; diff --git a/src/main/java/org/opensearch/security/support/ReflectionHelper.java b/src/main/java/org/opensearch/security/support/ReflectionHelper.java index c17a70add2..317b954ecc 100644 --- a/src/main/java/org/opensearch/security/support/ReflectionHelper.java +++ b/src/main/java/org/opensearch/security/support/ReflectionHelper.java @@ -39,8 +39,8 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; @@ -51,7 +51,7 @@ public class ReflectionHelper { - protected static final Logger log = LogManager.getLogger(ReflectionHelper.class); + protected static final Logger log = LoggerFactory.getLogger(ReflectionHelper.class); private static Set modulesLoaded = new HashSet<>(); diff --git a/src/main/java/org/opensearch/security/support/SecurityUtils.java b/src/main/java/org/opensearch/security/support/SecurityUtils.java index 2b4c725e6b..229a9e8cf9 100644 --- a/src/main/java/org/opensearch/security/support/SecurityUtils.java +++ b/src/main/java/org/opensearch/security/support/SecurityUtils.java @@ -41,15 +41,15 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.security.tools.Hasher; public final class SecurityUtils { - protected final static Logger log = LogManager.getLogger(SecurityUtils.class); + protected final static Logger log = LoggerFactory.getLogger(SecurityUtils.class); private static final Pattern ENV_PATTERN = Pattern.compile("\\$\\{env\\.([\\w]+)((\\:\\-)?[\\w]*)\\}"); private static final Pattern ENVBC_PATTERN = Pattern.compile("\\$\\{envbc\\.([\\w]+)((\\:\\-)?[\\w]*)\\}"); private static final Pattern ENVBASE64_PATTERN = Pattern.compile("\\$\\{envbase64\\.([\\w]+)((\\:\\-)?[\\w]*)\\}"); diff --git a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java index 2674f1940e..b4b9146ad8 100644 --- a/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java +++ b/src/main/java/org/opensearch/security/support/SnapshotRestoreHelper.java @@ -36,8 +36,8 @@ import java.util.Objects; import org.opensearch.security.OpenSearchSecurityPlugin; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.SpecialPermission; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.action.support.PlainActionFuture; @@ -50,7 +50,7 @@ public class SnapshotRestoreHelper { - protected static final Logger log = LogManager.getLogger(SnapshotRestoreHelper.class); + protected static final Logger log = LoggerFactory.getLogger(SnapshotRestoreHelper.class); public static List resolveOriginalIndices(RestoreSnapshotRequest restoreRequest) { final SnapshotInfo snapshotInfo = getSnapshotInfo(restoreRequest); diff --git a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java index 1ddc8dae25..069074bc85 100644 --- a/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java +++ b/src/main/java/org/opensearch/security/transport/DefaultInterClusterRequestEvaluator.java @@ -41,8 +41,8 @@ import org.opensearch.security.securityconf.DynamicConfigFactory; import org.opensearch.security.securityconf.NodesDnModel; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Settings; import org.opensearch.transport.TransportRequest; @@ -53,7 +53,7 @@ public final class DefaultInterClusterRequestEvaluator implements InterClusterRequestEvaluator { - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final String certOid; private final WildcardMatcher staticNodesDnFromEsYml; private boolean dynamicNodesDnConfigEnabled; diff --git a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java index f0e3957fd5..fd6d309d9f 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java +++ b/src/main/java/org/opensearch/security/transport/SecurityInterceptor.java @@ -39,8 +39,8 @@ import org.opensearch.security.OpenSearchSecurityPlugin; import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.opensearch.action.get.GetRequest; @@ -82,7 +82,7 @@ public class SecurityInterceptor { - protected final Logger log = LogManager.getLogger(getClass()); + protected final Logger log = LoggerFactory.getLogger(getClass()); private BackendRegistry backendRegistry; private AuditLog auditLog; private final ThreadPool threadPool; diff --git a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java index 176079d966..6786e4fed6 100644 --- a/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java +++ b/src/main/java/org/opensearch/security/transport/SecurityRequestHandler.java @@ -277,7 +277,7 @@ else if(!Strings.isNullOrEmpty(injectedUserHeader)) { if(SSLRequestHelper.containsBadHeader(getThreadContext(), ConfigConstants.OPENDISTRO_SECURITY_CONFIG_PREFIX)) { final OpenSearchException exception = ExceptionUtils.createBadHeaderException(); auditLog.logBadHeaders(request, task.getAction(), task); - log.error(exception); + log.error(exception.toString()); transportChannel.sendResponse(exception); return; } 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 63c3adf0ef..6e8d7e4ea2 100644 --- a/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java +++ b/src/main/java/org/opensearch/security/util/ratetracking/HeapBasedRateTracker.java @@ -21,8 +21,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -31,7 +31,7 @@ public class HeapBasedRateTracker implements RateTracker { - private final Logger log = LogManager.getLogger(this.getClass()); + private final Logger log = LoggerFactory.getLogger(this.getClass()); private final Cache cache; private final long timeWindowMs; 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 92e103e9cb..5c8b073246 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 @@ -29,8 +29,8 @@ 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.opensearch.security.test.helper.file.FileHelper; import org.opensearch.security.test.helper.network.SocketUtils; @@ -48,7 +48,7 @@ import com.unboundid.util.ssl.TrustStoreTrustManager; final class LdapServer { - private final static Logger LOG = LogManager.getLogger(LdapServer.class); + private final static Logger LOG = LoggerFactory.getLogger(LdapServer.class); private static final int LOCK_TIMEOUT = 60; private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS; diff --git a/src/test/java/org/opensearch/security/ResolveAPITests.java b/src/test/java/org/opensearch/security/ResolveAPITests.java index 95d06f7189..d0934d41dc 100644 --- a/src/test/java/org/opensearch/security/ResolveAPITests.java +++ b/src/test/java/org/opensearch/security/ResolveAPITests.java @@ -16,8 +16,8 @@ package org.opensearch.security; import org.apache.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.junit.Assert; import org.junit.Test; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; @@ -34,7 +34,7 @@ public class ResolveAPITests extends SingleClusterTest { - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); @Test public void testResolveDnfofFalse() throws Exception { diff --git a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java index 618c1ab5a5..586d38c7bc 100644 --- a/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/RolesInjectorIntegTest.java @@ -130,7 +130,7 @@ public void testRolesInject() throws Exception { Assert.assertTrue(cir.isAcknowledged()); } catch (OpenSearchSecurityException ex) { exception = ex; - log.warn(ex); + log.warn(ex.toString()); } Assert.assertNotNull(exception); Assert.assertTrue(exception.getMessage().contains("indices:admin/create")); diff --git a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java index 5ce4f87b6c..1c37093573 100644 --- a/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java +++ b/src/test/java/org/opensearch/security/TransportUserInjectorIntegTest.java @@ -109,7 +109,7 @@ public void testSecurityUserInjection() throws Exception { Assert.fail("Expecting exception"); } catch (OpenSearchSecurityException ex) { exception = ex; - log.warn(ex); + log.warn(ex.toString()); Assert.assertNotNull(exception); Assert.assertTrue(exception.getMessage().contains("indices:admin/create")); } diff --git a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java index b0582c1aac..90e5010b4b 100644 --- a/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java +++ b/src/test/java/org/opensearch/security/ccstest/CrossClusterSearchTests.java @@ -1069,7 +1069,7 @@ public void testCcsWithRoleInjection() throws Exception { Assert.assertEquals(getRes.getId(), "0"); } catch (OpenSearchSecurityException ex) { exception = ex; - log.warn(ex); + log.warn(ex.toString()); } Assert.assertNotNull(exception); Assert.assertTrue(exception.getMessage().contains("no permissions for")); @@ -1089,7 +1089,7 @@ public void testCcsWithRoleInjection() throws Exception { Assert.assertEquals(getRes.getId(), "0"); } catch (OpenSearchSecurityException ex) { Assert.assertNull(ex); - log.warn(ex); + log.warn(ex.toString()); } } } diff --git a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java index cbcf4c2e2a..24c6d8f06e 100644 --- a/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java +++ b/src/test/java/org/opensearch/security/ssl/CertificateValidatorTest.java @@ -30,8 +30,8 @@ import java.util.Collections; import java.util.Date; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.ExceptionsHelper; import org.junit.Assert; import org.junit.Test; @@ -43,7 +43,7 @@ public class CertificateValidatorTest { public static final Date CRL_DATE = new Date(1525546426000L); - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); @Test public void testStaticCRL() throws Exception { diff --git a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java index cbe0269988..5fe9669f9a 100644 --- a/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java +++ b/src/test/java/org/opensearch/security/test/AbstractSecurityUnitTest.java @@ -44,8 +44,8 @@ import org.apache.http.Header; import org.apache.http.message.BasicHeader; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.get.GetRequest; @@ -96,7 +96,7 @@ public abstract class AbstractSecurityUnitTest { //System.setProperty("security.display_lic_none","true"); } - protected final Logger log = LogManager.getLogger(this.getClass()); + protected final Logger log = LoggerFactory.getLogger(this.getClass()); public static final ThreadPool MOCK_POOL = new ThreadPool(Settings.builder().put("node.name", "mock").build()); //TODO Test Matrix 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 702fd798ec..1ebd46cec6 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 @@ -43,8 +43,8 @@ import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.OpenSearchTimeoutException; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.node.info.NodeInfo; @@ -75,7 +75,7 @@ public final class ClusterHelper { System.setProperty("security.default_init.dir", new File("./securityconfig").getAbsolutePath()); } - protected final Logger log = LogManager.getLogger(ClusterHelper.class); + protected final Logger log = LoggerFactory.getLogger(ClusterHelper.class); protected final List opensearchNodes = new LinkedList<>(); 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 7856794af0..ba8cc17346 100644 --- a/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/file/FileHelper.java @@ -47,8 +47,8 @@ import java.security.KeyStore; import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentBuilder; @@ -60,7 +60,7 @@ public class FileHelper { - protected final static Logger log = LogManager.getLogger(FileHelper.class); + protected final static Logger log = LoggerFactory.getLogger(FileHelper.class); public static KeyStore getKeystoreFromClassPath(final String fileNameFromClasspath, String password) throws Exception { Path path = getAbsoluteFilePathFromClassPath(fileNameFromClasspath); 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 4f644d7f05..531cf2bf98 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 @@ -68,15 +68,15 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Logger; import org.opensearch.security.test.helper.cluster.ClusterInfo; import org.opensearch.security.test.helper.file.FileHelper; public class RestHelper { - protected final Logger log = LogManager.getLogger(RestHelper.class); + protected final Logger log = LoggerFactory.getLogger(RestHelper.class); public boolean enableHTTPClientSSL = true; public boolean enableHTTPClientSSLv3Only = false; From 0a81c1388bf5be41a344b7ecd776d002767d3f47 Mon Sep 17 00:00:00 2001 From: Dave Lago Date: Fri, 7 Jan 2022 15:25:26 -0500 Subject: [PATCH 4/4] Adding log4j-core as test dependency Signed-off-by: Dave Lago --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 0eedf93edd..452e69cb34 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,7 @@ 2.0.25.Final 1.67 + 2.17.1 1.7.32 25.1-jre 1.3.1 @@ -221,6 +222,13 @@ ${slf4j.version} + + org.apache.logging.log4j + log4j-core + ${log4j.version} + test + + org.ldaptive ldaptive