Below you'll find my exception resolver (working)
Code:
/**
* AuthenticationAwareExceptionResolver
*
* Project: Gigacube
* Copyright (c) 2009 - 2010, Introde, All rights reserved.
*
* @author Tomek
*/
package com.gigacube.security.web.servlet.handler;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
public class AuthenticationAwareExceptionResolver extends SimpleMappingExceptionResolver {
/* (non-Javadoc)
* @see org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#setExceptionMappings(java.util.Properties)
* Fills exceptions mappings with AuthenticationCredentialsNotFoundException
*/
@Override
public void setExceptionMappings(Properties mappings) {
Assert.notNull(mappings);
mappings.put(
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException.class
.getCanonicalName(), "");
super.setExceptionMappings(mappings);
}
/* (non-Javadoc)
* @see org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#determineViewName(java.lang.Exception, javax.servlet.http.HttpServletRequest)
* Because Properties values can't be null we must manually return null
*/
@Override
protected String determineViewName(Exception ex, HttpServletRequest request) {
String viewName = super.determineViewName(ex, request);
return StringUtils.hasText(viewName) ? viewName : null;
}
}