提交 0d3819bb 编写于 作者: O Olivier Lamy

Merge pull request #1155 from msrb/logging

Switch to java.util.logging on few places
...@@ -28,8 +28,6 @@ import org.acegisecurity.ui.AuthenticationEntryPoint; ...@@ -28,8 +28,6 @@ import org.acegisecurity.ui.AuthenticationEntryPoint;
import org.acegisecurity.ui.savedrequest.SavedRequest; import org.acegisecurity.ui.savedrequest.SavedRequest;
import org.acegisecurity.util.PortResolver; import org.acegisecurity.util.PortResolver;
import org.acegisecurity.util.PortResolverImpl; import org.acegisecurity.util.PortResolverImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert; import org.springframework.util.Assert;
...@@ -42,6 +40,8 @@ import javax.servlet.ServletResponse; ...@@ -42,6 +40,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Handles any <code>AccessDeniedException</code> and <code>AuthenticationException</code> thrown within the * Handles any <code>AccessDeniedException</code> and <code>AuthenticationException</code> thrown within the
...@@ -85,7 +85,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean { ...@@ -85,7 +85,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean {
//~ Static fields/initializers ===================================================================================== //~ Static fields/initializers =====================================================================================
private static final Log logger = LogFactory.getLog(ExceptionTranslationFilter.class); private static final Logger LOGGER = Logger.getLogger(ExceptionTranslationFilter.class.getName());
//~ Instance fields ================================================================================================ //~ Instance fields ================================================================================================
...@@ -116,9 +116,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean { ...@@ -116,9 +116,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean {
try { try {
chain.doFilter(request, response); chain.doFilter(request, response);
if (logger.isDebugEnabled()) { LOGGER.finer("Chain processed normally");
logger.debug("Chain processed normally");
}
} }
catch (AuthenticationException ex) { catch (AuthenticationException ex) {
handleException(request, response, chain, ex); handleException(request, response, chain, ex);
...@@ -155,27 +153,21 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean { ...@@ -155,27 +153,21 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean {
private void handleException(ServletRequest request, ServletResponse response, FilterChain chain, private void handleException(ServletRequest request, ServletResponse response, FilterChain chain,
AcegiSecurityException exception) throws IOException, ServletException { AcegiSecurityException exception) throws IOException, ServletException {
if (exception instanceof AuthenticationException) { if (exception instanceof AuthenticationException) {
if (logger.isDebugEnabled()) { LOGGER.log(Level.FINER, "Authentication exception occurred; redirecting to authentication entry point", exception);
logger.debug("Authentication exception occurred; redirecting to authentication entry point", exception);
}
sendStartAuthentication(request, response, chain, (AuthenticationException) exception); sendStartAuthentication(request, response, chain, (AuthenticationException) exception);
} }
else if (exception instanceof AccessDeniedException) { else if (exception instanceof AccessDeniedException) {
if (authenticationTrustResolver.isAnonymous(SecurityContextHolder.getContext().getAuthentication())) { if (authenticationTrustResolver.isAnonymous(SecurityContextHolder.getContext().getAuthentication())) {
if (logger.isDebugEnabled()) { LOGGER.log(Level.FINER, "Access is denied (user is anonymous); redirecting to authentication entry point",
logger.debug("Access is denied (user is anonymous); redirecting to authentication entry point", exception);
exception);
}
sendStartAuthentication(request, response, chain, new InsufficientAuthenticationException( sendStartAuthentication(request, response, chain, new InsufficientAuthenticationException(
"Full authentication is required to access this resource",exception)); "Full authentication is required to access this resource",exception));
} }
else { else {
if (logger.isDebugEnabled()) { LOGGER.log(Level.FINER, "Access is denied (user is not anonymous); delegating to AccessDeniedHandler",
logger.debug("Access is denied (user is not anonymous); delegating to AccessDeniedHandler", exception);
exception);
}
accessDeniedHandler.handle(request, response, (AccessDeniedException) exception); accessDeniedHandler.handle(request, response, (AccessDeniedException) exception);
} }
...@@ -205,9 +197,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean { ...@@ -205,9 +197,7 @@ public class ExceptionTranslationFilter implements Filter, InitializingBean {
SavedRequest savedRequest = new SavedRequest(httpRequest, portResolver); SavedRequest savedRequest = new SavedRequest(httpRequest, portResolver);
if (logger.isDebugEnabled()) { LOGGER.finer("Authentication entry point being called; SavedRequest added to Session: " + savedRequest);
logger.debug("Authentication entry point being called; SavedRequest added to Session: " + savedRequest);
}
if (createSessionAllowed) { if (createSessionAllowed) {
// Store the HTTP request itself. Used by AbstractProcessingFilter // Store the HTTP request itself. Used by AbstractProcessingFilter
......
...@@ -9,14 +9,14 @@ import java.io.FileOutputStream; ...@@ -9,14 +9,14 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
public class ZipArchiverTest extends TestCase { public class ZipArchiverTest extends TestCase {
private final Log logger = LogFactory.getLog(getClass()); private static final Logger LOGGER = Logger.getLogger(ZipArchiverTest.class.getName());
private File tmpDir; private File tmpDir;
...@@ -103,7 +103,7 @@ public class ZipArchiverTest extends TestCase { ...@@ -103,7 +103,7 @@ public class ZipArchiverTest extends TestCase {
* @param cause the root cause of the failure * @param cause the root cause of the failure
*/ */
private final void fail(final String msg, final Throwable cause) { private final void fail(final String msg, final Throwable cause) {
logger.error(msg, cause); LOGGER.log(Level.SEVERE, msg, cause);
fail(msg); fail(msg);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册