public class

OpenIDAuthenticationFilter

extends AbstractAuthenticationProcessingFilter
java.lang.Object
   ↳ org.springframework.web.filter.GenericFilterBean
     ↳ org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
       ↳ org.springframework.security.openid.OpenIDAuthenticationFilter

Class Overview

Filter which processes OpenID authentication requests.

The OpenID authentication involves two stages.

Submission of OpenID identity

The user's OpenID identity is submitted via a login form, just as it would be for a normal form login. At this stage the filter will extract the identity from the submitted request (by default, the parameter is called openid_identifier, as recommended by the OpenID 2.0 Specification). It then passes the identity to the configured OpenIDConsumer, which returns the URL to which the request should be redirected for authentication. A "return_to" URL is also supplied, which matches the URL processed by this filter, to allow the filter to handle the request once the user has been successfully authenticated. The OpenID server will then authenticate the user and redirect back to the application.

Processing the Redirect from the OpenID Server

Once the user has been authenticated externally, the redirected request will be passed to the OpenIDConsumer again for validation. The returned OpenIDAuthentication will be passed to the AuthenticationManager where it should (normally) be processed by an OpenIDAuthenticationProvider in order to load the authorities for the user.

Summary

Constants
String DEFAULT_CLAIMED_IDENTITY_FIELD
[Expand]
Inherited Constants
From class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
[Expand]
Inherited Fields
From class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
From class org.springframework.web.filter.GenericFilterBean
Public Constructors
OpenIDAuthenticationFilter()
Public Methods
void afterPropertiesSet()
Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
Authentication has two phases.
void setClaimedIdentityFieldName(String claimedIdentityFieldName)
The name of the request parameter containing the OpenID identity, as submitted from the initial login form.
void setConsumer(OpenIDConsumer consumer)
void setRealmMapping(Map<StringString> realmMapping)
Maps the return_to url to a realm, for example:
 http://www.example.com/j_spring_openid_security_check -> http://www.example.com/realm
 
If no mapping is provided then the returnToUrl will be parsed to extract the protocol, hostname and port followed by a trailing slash.
void setReturnToUrlParameters(Set<String> returnToUrlParameters)
Specifies any extra parameters submitted along with the identity field which should be appended to the return_to URL which is assembled by buildReturnToUrl(HttpServletRequest).
Protected Methods
String buildReturnToUrl(HttpServletRequest request)
Builds the return_to URL that will be sent to the OpenID service provider.
String lookupRealm(String returnToUrl)
String obtainUsername(HttpServletRequest req)
Reads the claimedIdentityFieldName from the submitted request.
[Expand]
Inherited Methods
From class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
From class org.springframework.web.filter.GenericFilterBean
From class java.lang.Object
From interface javax.servlet.Filter
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.context.ApplicationEventPublisherAware
From interface org.springframework.context.MessageSourceAware
From interface org.springframework.web.context.ServletContextAware

Constants

public static final String DEFAULT_CLAIMED_IDENTITY_FIELD

Constant Value: "openid_identifier"

Public Constructors

public OpenIDAuthenticationFilter ()

Public Methods

public void afterPropertiesSet ()

public Authentication attemptAuthentication (HttpServletRequest request, HttpServletResponse response)

Authentication has two phases.

  1. The initial submission of the claimed OpenID. A redirect to the URL returned from the consumer will be performed and null will be returned.
  2. The redirection from the OpenID server to the return_to URL, once it has authenticated the user

Parameters
request from which to extract parameters and perform the authentication
response the response, which may be needed if the implementation has to do a redirect as part of a multi-stage authentication process (such as OpenID).
Returns
  • the authenticated user token, or null if authentication is incomplete.

public void setClaimedIdentityFieldName (String claimedIdentityFieldName)

The name of the request parameter containing the OpenID identity, as submitted from the initial login form.

Parameters
claimedIdentityFieldName defaults to "openid_identifier"

public void setConsumer (OpenIDConsumer consumer)

public void setRealmMapping (Map<StringString> realmMapping)

Maps the return_to url to a realm, for example:

 http://www.example.com/j_spring_openid_security_check -> http://www.example.com/realm
 
If no mapping is provided then the returnToUrl will be parsed to extract the protocol, hostname and port followed by a trailing slash. This means that http://www.example.com/j_spring_openid_security_check will automatically become http://www.example.com:80/

Parameters
realmMapping containing returnToUrl -> realm mappings

public void setReturnToUrlParameters (Set<String> returnToUrlParameters)

Specifies any extra parameters submitted along with the identity field which should be appended to the return_to URL which is assembled by buildReturnToUrl(HttpServletRequest).

Parameters
returnToUrlParameters the set of parameter names. If not set, it will default to the parameter name used by the RememberMeServices obtained from the parent class (if one is set).

Protected Methods

protected String buildReturnToUrl (HttpServletRequest request)

Builds the return_to URL that will be sent to the OpenID service provider. By default returns the URL of the current request.

Parameters
request the current request which is being processed by this filter
Returns
  • The return_to URL.

protected String lookupRealm (String returnToUrl)

protected String obtainUsername (HttpServletRequest req)

Reads the claimedIdentityFieldName from the submitted request.