Search in sources :

Example 66 with Log

use of org.apache.commons.logging.Log in project javaee7-samples by javaee-samples.

the class SecureServletTest method enableSSLDebug.

private static void enableSSLDebug() {
    System.setProperty("javax.net.debug", "ssl:handshake");
    System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "debug");
    Logger.getLogger("com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory").setLevel(FINEST);
    Logger.getLogger("org.apache.http.conn.ssl.SSLConnectionSocketFactory").setLevel(FINEST);
    Log logger = LogFactory.getLog(org.apache.http.conn.ssl.SSLConnectionSocketFactory.class);
    ((Jdk14Logger) logger).getLogger().setLevel(FINEST);
    logger = LogFactory.getLog(com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.class);
    ((Jdk14Logger) logger).getLogger().setLevel(FINEST);
    Logger.getGlobal().getParent().getHandlers()[0].setLevel(FINEST);
}
Also used : Log(org.apache.commons.logging.Log)

Example 67 with Log

use of org.apache.commons.logging.Log in project javaee7-samples by javaee-samples.

the class SecureServletTest method enableSSLDebug.

private static void enableSSLDebug() {
    System.setProperty("javax.net.debug", "ssl:handshake");
    System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "debug");
    Logger.getLogger("com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory").setLevel(FINEST);
    Logger.getLogger("org.apache.http.conn.ssl.SSLConnectionSocketFactory").setLevel(FINEST);
    Log logger = LogFactory.getLog(org.apache.http.conn.ssl.SSLConnectionSocketFactory.class);
    ((Jdk14Logger) logger).getLogger().setLevel(FINEST);
    logger = LogFactory.getLog(com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.class);
    ((Jdk14Logger) logger).getLogger().setLevel(FINEST);
    Logger.getGlobal().getParent().getHandlers()[0].setLevel(FINEST);
}
Also used : Log(org.apache.commons.logging.Log)

Example 68 with Log

use of org.apache.commons.logging.Log in project spring-security by spring-projects.

the class DefaultJaasAuthenticationProviderTests method setUp.

@BeforeEach
public void setUp() throws Exception {
    Configuration configuration = mock(Configuration.class);
    this.publisher = mock(ApplicationEventPublisher.class);
    this.log = mock(Log.class);
    this.provider = new DefaultJaasAuthenticationProvider();
    this.provider.setConfiguration(configuration);
    this.provider.setApplicationEventPublisher(this.publisher);
    this.provider.setAuthorityGranters(new AuthorityGranter[] { new TestAuthorityGranter() });
    this.provider.afterPropertiesSet();
    AppConfigurationEntry[] aces = new AppConfigurationEntry[] { new AppConfigurationEntry(TestLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap()) };
    given(configuration.getAppConfigurationEntry(this.provider.getLoginContextName())).willReturn(aces);
    this.token = new UsernamePasswordAuthenticationToken("user", "password");
    ReflectionTestUtils.setField(this.provider, "log", this.log);
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) Configuration(javax.security.auth.login.Configuration) Log(org.apache.commons.logging.Log) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 69 with Log

use of org.apache.commons.logging.Log in project spring-security by spring-projects.

the class AbstractAuthenticationProcessingFilterTests method loginErrorWithInternAuthenticationServiceExceptionLogsError.

/**
 * SEC-1919
 */
@Test
public void loginErrorWithInternAuthenticationServiceExceptionLogsError() throws Exception {
    MockHttpServletRequest request = createMockAuthenticationRequest();
    MockFilterChain chain = new MockFilterChain(true);
    MockHttpServletResponse response = new MockHttpServletResponse();
    Log logger = mock(Log.class);
    MockAuthenticationFilter filter = new MockAuthenticationFilter(false);
    ReflectionTestUtils.setField(filter, "logger", logger);
    filter.exceptionToThrow = new InternalAuthenticationServiceException("Mock requested to do so");
    this.successHandler.setDefaultTargetUrl("https://monkeymachine.co.uk/");
    filter.setAuthenticationSuccessHandler(this.successHandler);
    filter.doFilter(request, response, chain);
    verify(logger).error(anyString(), eq(filter.exceptionToThrow));
    assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_UNAUTHORIZED);
}
Also used : Log(org.apache.commons.logging.Log) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) InternalAuthenticationServiceException(org.springframework.security.authentication.InternalAuthenticationServiceException) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Example 70 with Log

use of org.apache.commons.logging.Log in project spring-security by spring-projects.

the class HttpSessionEventPublisher method extracted.

private void extracted(HttpSession session, ApplicationEvent e) {
    Log log = LogFactory.getLog(LOGGER_NAME);
    log.debug(LogMessage.format("Publishing event: %s", e));
    getContext(session.getServletContext()).publishEvent(e);
}
Also used : Log(org.apache.commons.logging.Log)

Aggregations

Log (org.apache.commons.logging.Log)188 Test (org.junit.Test)51 Test (org.junit.jupiter.api.Test)40 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)35 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)19 BeanFactory (org.springframework.beans.factory.BeanFactory)17 CountDownLatch (java.util.concurrent.CountDownLatch)15 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)15 ArrayList (java.util.ArrayList)12 File (java.io.File)11 QueueChannel (org.springframework.integration.channel.QueueChannel)11 MethodInvocation (org.aopalliance.intercept.MethodInvocation)10 IOException (java.io.IOException)9 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)9 Message (org.springframework.messaging.Message)8 List (java.util.List)7 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)7 InputStream (java.io.InputStream)6 LogFactory (org.apache.commons.logging.LogFactory)6