List of usage examples for org.springframework.security.oauth.consumer AccessTokenRequiredException getMessage
public String getMessage()
From source file:org.springframework.security.oauth.consumer.filter.OAuthConsumerContextFilter.java
/** * Check the given exception for the resource that needs authorization. If the exception was not thrown because a resource needed authorization, then rethrow * the exception.//from w ww. j a va 2 s .c o m * * @param ex The exception. * @return The resource that needed authorization (never null). */ protected ProtectedResourceDetails checkForResourceThatNeedsAuthorization(Exception ex) throws ServletException, IOException { Throwable[] causeChain = getThrowableAnalyzer().determineCauseChain(ex); AccessTokenRequiredException ase = (AccessTokenRequiredException) getThrowableAnalyzer() .getFirstThrowableOfType(AccessTokenRequiredException.class, causeChain); ProtectedResourceDetails resourceThatNeedsAuthorization; if (ase != null) { resourceThatNeedsAuthorization = ase.getResource(); if (resourceThatNeedsAuthorization == null) { throw new OAuthRequestFailedException(ase.getMessage()); } } else { // Rethrow ServletExceptions and RuntimeExceptions as-is if (ex instanceof ServletException) { throw (ServletException) ex; } if (ex instanceof IOException) { throw (IOException) ex; } else if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } // Wrap other Exceptions. These are not expected to happen throw new RuntimeException(ex); } return resourceThatNeedsAuthorization; }