com.dyuproject.openid
Class OpenIdServletFilter

java.lang.Object
  extended by com.dyuproject.openid.OpenIdServletFilter
All Implemented Interfaces:
Filter

public class OpenIdServletFilter
extends Object
implements Filter

A servlet filter that forwards users to the login page if they are not authenticated and redirects the user to their openid provider once they've submitted their openid identifier. The required web.xml configuration is the init-parameter "forwardUri".

Author:
David Yu
Date created:
Jan 8, 2009

Nested Class Summary
static interface OpenIdServletFilter.ForwardUriHandler
          Pluggable handler to dispatch the request to a view/template.
 
Field Summary
protected  OpenIdServletFilter.ForwardUriHandler _forwardHandler
           
protected  String _forwardUri
           
protected  RelyingParty _relyingParty
           
static String DEFAULT_ERROR_MSG
           
static OpenIdServletFilter.ForwardUriHandler DEFAULT_FORWARD_URI_HANDLER
          The default forward uri handler that basically executes: request.getRequestDispatcher(forwardUri).forward(request, response);
static String ERROR_MSG_ATTR
           
static String ID_NOT_FOUND_MSG
           
 
Constructor Summary
OpenIdServletFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
          Delegates to the filter chain if the user associated with this request is authenticated.
 String getForwardUri()
          Gets the configured forward uri.
 RelyingParty getRelyingParty()
          Gets the configured relying party.
 boolean handle(HttpServletRequest request, HttpServletResponse response)
          Returns true if the user associated with this request is authenticated.
static boolean handle(HttpServletRequest request, HttpServletResponse response, RelyingParty relyingParty, OpenIdServletFilter.ForwardUriHandler forwardUriHandler, String forwardUri)
          Returns true if the user associated with this request is authenticated.
static boolean handle(HttpServletRequest request, HttpServletResponse response, String forwardUri)
          Returns true if the user associated with this request is authenticated.
 void init(FilterConfig config)
          This method is called by the servlet container to configure this filter; The init parameter "forwardUri" is required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_MSG_ATTR

public static final String ERROR_MSG_ATTR
See Also:
Constant Field Values

DEFAULT_ERROR_MSG

public static final String DEFAULT_ERROR_MSG

ID_NOT_FOUND_MSG

public static final String ID_NOT_FOUND_MSG

DEFAULT_FORWARD_URI_HANDLER

public static final OpenIdServletFilter.ForwardUriHandler DEFAULT_FORWARD_URI_HANDLER
The default forward uri handler that basically executes: request.getRequestDispatcher(forwardUri).forward(request, response);


_forwardUri

protected String _forwardUri

_relyingParty

protected RelyingParty _relyingParty

_forwardHandler

protected OpenIdServletFilter.ForwardUriHandler _forwardHandler
Constructor Detail

OpenIdServletFilter

public OpenIdServletFilter()
Method Detail

init

public void init(FilterConfig config)
          throws ServletException
This method is called by the servlet container to configure this filter; The init parameter "forwardUri" is required. The relying party used will be the default instance if it is not found in the servlet context attributes.

Specified by:
init in interface Filter
Throws:
ServletException

getForwardUri

public String getForwardUri()
Gets the configured forward uri.


getRelyingParty

public RelyingParty getRelyingParty()
Gets the configured relying party.


doFilter

public void doFilter(ServletRequest req,
                     ServletResponse res,
                     FilterChain chain)
              throws IOException,
                     ServletException
Delegates to the filter chain if the user associated with this request is authenticated.

Specified by:
doFilter in interface Filter
Throws:
IOException
ServletException

destroy

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

handle

public boolean handle(HttpServletRequest request,
                      HttpServletResponse response)
               throws IOException,
                      ServletException
Returns true if the user associated with this request is authenticated.

Throws:
IOException
ServletException

handle

public static boolean handle(HttpServletRequest request,
                             HttpServletResponse response,
                             String forwardUri)
                      throws IOException,
                             ServletException
Returns true if the user associated with this request is authenticated.

Throws:
IOException
ServletException

handle

public static boolean handle(HttpServletRequest request,
                             HttpServletResponse response,
                             RelyingParty relyingParty,
                             OpenIdServletFilter.ForwardUriHandler forwardUriHandler,
                             String forwardUri)
                      throws IOException,
                             ServletException
Returns true if the user associated with this request is authenticated.

Throws:
IOException
ServletException


Copyright © 2008-2013. All Rights Reserved.