org.springframework.security.oauth2.client.filter
Class OAuth2ClientContextFilter

java.lang.Object
  extended by org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter
All Implemented Interfaces:
Filter, InitializingBean

public class OAuth2ClientContextFilter
extends Object
implements Filter, InitializingBean

Security filter for an OAuth2 client.

Author:
Ryan Heaton, Dave Syer

Field Summary
static String CURRENT_URI
          Key in request attributes for the current URI in case it is needed by rest client code that needs to send a redirect URI to an authorization server.
 
Constructor Summary
OAuth2ClientContextFilter()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  String calculateCurrentUri(HttpServletRequest request)
          Calculate the current URI given the request.
protected  OAuth2ProtectedResourceDetails checkForResourceThatNeedsAuthorization(Exception ex)
          Check the given exception for the resource that needs authorization.
 void destroy()
           
 void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
           
 void init(FilterConfig filterConfig)
           
protected  void redirectUser(UserRedirectRequiredException e, HttpServletRequest request, HttpServletResponse response)
          Redirect the user according to the specified exception.
 void setPortResolver(org.springframework.security.web.PortResolver portResolver)
           
 void setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy)
           
 void setThrowableAnalyzer(org.springframework.security.web.util.ThrowableAnalyzer throwableAnalyzer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_URI

public static final String CURRENT_URI
Key in request attributes for the current URI in case it is needed by rest client code that needs to send a redirect URI to an authorization server.

See Also:
Constant Field Values
Constructor Detail

OAuth2ClientContextFilter

public OAuth2ClientContextFilter()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

doFilter

public void doFilter(ServletRequest servletRequest,
                     ServletResponse servletResponse,
                     FilterChain chain)
              throws IOException,
                     ServletException
Specified by:
doFilter in interface Filter
Throws:
IOException
ServletException

redirectUser

protected void redirectUser(UserRedirectRequiredException e,
                            HttpServletRequest request,
                            HttpServletResponse response)
                     throws IOException
Redirect the user according to the specified exception.

Parameters:
resourceThatNeedsAuthorization -
e - The user redirect exception.
request - The request.
response - The response.
Throws:
IOException

checkForResourceThatNeedsAuthorization

protected OAuth2ProtectedResourceDetails checkForResourceThatNeedsAuthorization(Exception ex)
                                                                         throws ServletException,
                                                                                IOException
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.

Parameters:
ex - The exception.
Returns:
The resource that needed authorization (never null).
Throws:
ServletException
IOException

calculateCurrentUri

protected String calculateCurrentUri(HttpServletRequest request)
                              throws UnsupportedEncodingException
Calculate the current URI given the request.

Parameters:
request - The request.
Returns:
The current uri.
Throws:
UnsupportedEncodingException

init

public void init(FilterConfig filterConfig)
          throws ServletException
Specified by:
init in interface Filter
Throws:
ServletException

destroy

public void destroy()
Specified by:
destroy in interface Filter

setThrowableAnalyzer

public void setThrowableAnalyzer(org.springframework.security.web.util.ThrowableAnalyzer throwableAnalyzer)

setPortResolver

public void setPortResolver(org.springframework.security.web.PortResolver portResolver)

setRedirectStrategy

public void setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy)


Copyright © 2012. All Rights Reserved.