mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-08 11:32:47 +00:00
SEC-1136: Converted base exceptions to extend RuntimeException rather than NestedRuntimeException.
This commit is contained in:
parent
101203b44d
commit
292926518b
@ -15,16 +15,14 @@
|
|||||||
|
|
||||||
package org.springframework.security.access;
|
package org.springframework.security.access;
|
||||||
|
|
||||||
import org.springframework.core.NestedRuntimeException;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown if an {@link Authentication} object does not hold a required authority.
|
* Thrown if an {@link org.springframework.security.core.Authentication Authentication} object does not hold a
|
||||||
|
* required authority.
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class AccessDeniedException extends NestedRuntimeException {
|
public class AccessDeniedException extends RuntimeException {
|
||||||
//~ Constructors ===================================================================================================
|
//~ Constructors ===================================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
|
|
||||||
package org.springframework.security.core;
|
package org.springframework.security.core;
|
||||||
|
|
||||||
import org.springframework.core.NestedRuntimeException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract superclass for all exceptions related to an {@link Authentication} object being invalid for whatever
|
* Abstract superclass for all exceptions related to an {@link Authentication} object being invalid for whatever
|
||||||
* reason.
|
* reason.
|
||||||
@ -25,7 +22,7 @@ import org.springframework.core.NestedRuntimeException;
|
|||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class AuthenticationException extends NestedRuntimeException {
|
public abstract class AuthenticationException extends RuntimeException {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
|
|
||||||
private Authentication authentication;
|
private Authentication authentication;
|
||||||
|
@ -102,11 +102,11 @@ public class ExceptionTranslationFilter extends SpringSecurityFilter implements
|
|||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
// Try to extract a SpringSecurityException from the stacktrace
|
// Try to extract a SpringSecurityException from the stacktrace
|
||||||
Throwable[] causeChain = throwableAnalyzer.determineCauseChain(ex);
|
Throwable[] causeChain = throwableAnalyzer.determineCauseChain(ex);
|
||||||
NestedRuntimeException ase = (NestedRuntimeException)
|
RuntimeException ase = (AuthenticationException)
|
||||||
throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class, causeChain);
|
throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class, causeChain);
|
||||||
|
|
||||||
if (ase == null) {
|
if (ase == null) {
|
||||||
ase = (NestedRuntimeException)throwableAnalyzer.getFirstThrowableOfType(AccessDeniedException.class, causeChain);
|
ase = (AccessDeniedException)throwableAnalyzer.getFirstThrowableOfType(AccessDeniedException.class, causeChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ase != null) {
|
if (ase != null) {
|
||||||
@ -139,7 +139,7 @@ public class ExceptionTranslationFilter extends SpringSecurityFilter implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleException(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
|
private void handleException(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
|
||||||
NestedRuntimeException exception) throws IOException, ServletException {
|
RuntimeException exception) throws IOException, ServletException {
|
||||||
if (exception instanceof AuthenticationException) {
|
if (exception instanceof AuthenticationException) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Authentication exception occurred; redirecting to authentication entry point", exception);
|
logger.debug("Authentication exception occurred; redirecting to authentication entry point", exception);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user