com.force.sdk.oauth
Class AuthFilter

java.lang.Object
  extended by com.force.sdk.oauth.AuthFilter
All Implemented Interfaces:
com.sforce.ws.SessionRenewer, javax.servlet.Filter

public class AuthFilter
extends Object
implements javax.servlet.Filter, com.sforce.ws.SessionRenewer

This filter can be used to add Force.com OAuth Authentication to any web application. When configuring web.xml all requests that need to be authenticated should be sent through AuthFilter. The OAuth callback (usually _auth) must also be sent through AuthFilter. To use the connector, add the following servlet filter to your application's web.xml file:

<!-- Enables Security --> <filter> <filter-name>AuthFilter</filter-name> <filter-class>com.force.sdk.oauth.AuthFilter</filter-class> <init-param> <param-name>connectionName</param-name> <param-value>nameOfConnectionToUse</param-value> </init-param> </filter> <filter-mapping> <filter-name>AuthFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

The OAuth Connector uses the Force.com API Connector to access the Force.com APIs. The connectionName is used to look up OAuth properties defined in an environment variable, or a Java system property, or in a properties file on the classpath. See @doclink connection-url for more information. Other init parameters that can be set are:

Author:
Fiaz Hossain, John Simone

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sforce.ws.SessionRenewer
com.sforce.ws.SessionRenewer.SessionRenewalHeader
 
Constructor Summary
AuthFilter()
           
 
Method Summary
 void destroy()
          No resources to release.
 void doFilter(javax.servlet.ServletRequest sreq, javax.servlet.ServletResponse sres, javax.servlet.FilterChain chain)
          Handle the secured requests.
 SecurityContextService getSecurityContextService()
           
 void init(javax.servlet.FilterConfig config)
          Initialize the filter from the init params.
 com.sforce.ws.SessionRenewer.SessionRenewalHeader renewSession(com.sforce.ws.ConnectorConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthFilter

public AuthFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Initialize the filter from the init params.

Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest sreq,
                     javax.servlet.ServletResponse sres,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Handle the secured requests.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
IOException
javax.servlet.ServletException

destroy

public void destroy()
No resources to release.

Specified by:
destroy in interface javax.servlet.Filter

getSecurityContextService

public SecurityContextService getSecurityContextService()

renewSession

public com.sforce.ws.SessionRenewer.SessionRenewalHeader renewSession(com.sforce.ws.ConnectorConfig config)
                                                               throws com.sforce.ws.ConnectionException
Specified by:
renewSession in interface com.sforce.ws.SessionRenewer
Throws:
com.sforce.ws.ConnectionException


Copyright © 2011. All Rights Reserved.