com.force.sdk.springsecurity
Class ForceConnectionStorageFilter

java.lang.Object
  extended by org.springframework.web.filter.GenericFilterBean
      extended by com.force.sdk.springsecurity.ForceConnectionStorageFilter
All Implemented Interfaces:
com.sforce.ws.SessionRenewer, javax.servlet.Filter, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.web.context.ServletContextAware

public class ForceConnectionStorageFilter
extends org.springframework.web.filter.GenericFilterBean
implements com.sforce.ws.SessionRenewer

This filter should run after all other Force.com filters in the spring security chain. It ensures that the connection information of the authenticated user is set into the Force.com Connector framework so that it is available to other Force.com SDK frameworks. It's important that this filter run as the last Force.com Spring Security filter because it is important that the connection storage takes place regardless of which authentication method and data storage method was used. It's also important that the final result of the entire authentication chain is what gets stored in the connector. The logic to renew a session is also in this filter. This hook will be called as needed by the Spring Security Framework.

Author:
John Simone

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sforce.ws.SessionRenewer
com.sforce.ws.SessionRenewer.SessionRenewalHeader
 
Field Summary
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
ForceConnectionStorageFilter()
           
 
Method Summary
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 com.sforce.ws.SessionRenewer.SessionRenewalHeader renewSession(com.sforce.ws.ConnectorConfig config)
          We will renew a session by sending the user into the OAuth flow.
 void setOauthConnector(ForceOAuthConnector oauthConnector)
           
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForceConnectionStorageFilter

public ForceConnectionStorageFilter()
Method Detail

setOauthConnector

public void setOauthConnector(ForceOAuthConnector oauthConnector)

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException

renewSession

public com.sforce.ws.SessionRenewer.SessionRenewalHeader renewSession(com.sforce.ws.ConnectorConfig config)
                                                               throws com.sforce.ws.ConnectionException
We will renew a session by sending the user into the OAuth flow. A renewal attempt results in a runtime exception so that it can either be handled by an application or be allowed to bubble up to the servlet filter where the authentication redirect takes place.

Specified by:
renewSession in interface com.sforce.ws.SessionRenewer
Throws:
com.sforce.ws.ConnectionException


Copyright © 2011. All Rights Reserved.