org.opennms.web.acegisecurity
Class NtlmAuthenticationProcessingFilter

java.lang.Object
  extended by org.acegisecurity.providers.ldap.authenticator.AbstractLdapAuthenticator
      extended by org.acegisecurity.providers.ldap.authenticator.BindAuthenticator
          extended by org.opennms.web.acegisecurity.NtlmAuthenticationProcessingFilter
All Implemented Interfaces:
javax.servlet.Filter, org.acegisecurity.providers.ldap.LdapAuthenticator, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.MessageSourceAware

public class NtlmAuthenticationProcessingFilter
extends org.acegisecurity.providers.ldap.authenticator.BindAuthenticator
implements javax.servlet.Filter, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.MessageSourceAware

Processes an authentication form.

Login forms must present two parameters to this filter: a username and password. The parameter names to use are contained in the static fields #ACEGI_SECURITY_FORM_USERNAME_KEY and #ACEGI_SECURITY_FORM_PASSWORD_KEY.

Do not use this class directly. Instead configure web.xml to use the org.acegisecurity.util.FilterToBeanProxy.

Version:
$Id: AuthenticationProcessingFilter.java 1496 2006-05-23 13:38:33 +0000 (Tue, 23 May 2006) benalex $
Author:
Ben Alex, Colin Sampaleanu

Field Summary
protected  org.acegisecurity.ui.AuthenticationDetailsSource authenticationDetailsSource
           
protected  org.springframework.context.ApplicationEventPublisher eventPublisher
           
protected  org.springframework.context.support.MessageSourceAccessor messages
           
protected  java.util.List<java.lang.String> skipNtlmAuthUrls
           
 
Constructor Summary
NtlmAuthenticationProcessingFilter(org.acegisecurity.ldap.InitialDirContextFactory initialDirContextFactory)
           
 
Method Summary
 void afterPropertiesSet()
           
 org.acegisecurity.Authentication attemptAuthentication(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          This method simply calls negotiate( req, resp, false ) and then chain.doFilter.
 void destroy()
          Does nothing.
protected  java.lang.String determineTargetUrl(javax.servlet.http.HttpServletRequest request)
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 org.acegisecurity.ui.AuthenticationDetailsSource getAuthenticationDetailsSource()
           
 java.lang.String getDefaultDomain()
           
 java.lang.String getDefaultTargetUrl()
          Supplies the default target Url that will be used if no saved request is found or the alwaysUseDefaultTargetUrl propert is set to true.
 java.lang.String getDomainController()
           
 java.util.Properties getExceptionMappings()
           
 org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator getLdapAuthoritiesPopulator()
           
 java.util.Properties getProperties()
           
 java.lang.String getRealm()
           
 org.acegisecurity.ui.rememberme.RememberMeServices getRememberMeServices()
           
 java.util.List<java.lang.String> getSkipNtlmAuthUrls()
           
 void init(javax.servlet.FilterConfig arg0)
          Does JCIFS Initialization.
 boolean isAlwaysUseDefaultTargetUrl()
           
 boolean isEnableBasic()
           
 boolean isInsecureBasic()
           
 boolean isLoadBalance()
           
protected  jcifs.smb.NtlmPasswordAuthentication negotiate(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, boolean skipAuthentication)
          Negotiate password hashes with MSIE clients using NTLM SSP
protected  void onPreAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void onSuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.acegisecurity.Authentication authResult)
           
protected  void onUnsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.acegisecurity.AuthenticationException failed)
           
 void setAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl)
           
 void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher)
           
 void setAuthenticationDetailsSource(org.acegisecurity.ui.AuthenticationDetailsSource authenticationDetailsSource)
           
 void setDefaultDomain(java.lang.String defaultDomain)
           
 void setDefaultTargetUrl(java.lang.String defaultTargetUrl)
           
protected  void setDetails(javax.servlet.http.HttpServletRequest request, org.acegisecurity.providers.UsernamePasswordAuthenticationToken authRequest)
          Provided so that subclasses may configure what is put into the authentication request's details property.
 void setDomainController(java.lang.String domainController)
           
 void setEnableBasic(boolean enableBasic)
           
 void setExceptionMappings(java.util.Properties exceptionMappings)
           
 void setInsecureBasic(boolean insecureBasic)
           
 void setLdapAuthoritiesPopulator(org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator ldapAuthoritiesPopulator)
           
 void setLoadBalance(boolean loadBalance)
           
 void setMessageSource(org.springframework.context.MessageSource messageSource)
           
 void setProperties(java.util.Properties properties)
           
 void setRealm(java.lang.String realm)
           
 void setRememberMeServices(org.acegisecurity.ui.rememberme.RememberMeServices rememberMeServices)
           
 void setSkipNtlmAuthUrls(java.util.List<java.lang.String> skipNtlmAuthUrls)
           
protected  void successfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.acegisecurity.Authentication authResult)
           
protected  void unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.acegisecurity.AuthenticationException failed)
           
 
Methods inherited from class org.acegisecurity.providers.ldap.authenticator.BindAuthenticator
authenticate
 
Methods inherited from class org.acegisecurity.providers.ldap.authenticator.AbstractLdapAuthenticator
getInitialDirContextFactory, getUserAttributes, getUserDetailsMapper, getUserDns, getUserSearch, setUserAttributes, setUserDetailsMapper, setUserDnPatterns, setUserSearch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventPublisher

protected org.springframework.context.ApplicationEventPublisher eventPublisher

authenticationDetailsSource

protected org.acegisecurity.ui.AuthenticationDetailsSource authenticationDetailsSource

messages

protected org.springframework.context.support.MessageSourceAccessor messages

skipNtlmAuthUrls

protected java.util.List<java.lang.String> skipNtlmAuthUrls
Constructor Detail

NtlmAuthenticationProcessingFilter

public NtlmAuthenticationProcessingFilter(org.acegisecurity.ldap.InitialDirContextFactory initialDirContextFactory)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class org.acegisecurity.providers.ldap.authenticator.AbstractLdapAuthenticator
Throws:
java.lang.Exception

destroy

public void destroy()
Does nothing. We use IoC container lifecycle services instead.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

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

getDefaultTargetUrl

public java.lang.String getDefaultTargetUrl()
Supplies the default target Url that will be used if no saved request is found or the alwaysUseDefaultTargetUrl propert is set to true. Override this method of you want to provide a customized default Url (for example if you want different Urls depending on the authorities of the user who has just logged in).

Returns:
the defaultTargetUrl property

getExceptionMappings

public java.util.Properties getExceptionMappings()

getRememberMeServices

public org.acegisecurity.ui.rememberme.RememberMeServices getRememberMeServices()

init

public void init(javax.servlet.FilterConfig arg0)
          throws javax.servlet.ServletException
Does JCIFS Initialization. We use IoC container lifecycle services instead.

Specified by:
init in interface javax.servlet.Filter
Parameters:
arg0 - ignored
Throws:
javax.servlet.ServletException - ignored

attemptAuthentication

public org.acegisecurity.Authentication attemptAuthentication(javax.servlet.ServletRequest request,
                                                              javax.servlet.ServletResponse response,
                                                              javax.servlet.FilterChain chain)
                                                       throws java.io.IOException,
                                                              javax.servlet.ServletException,
                                                              org.acegisecurity.AuthenticationException
This method simply calls negotiate( req, resp, false ) and then chain.doFilter. You can override and call negotiate manually to achive a variety of different behavior.

Throws:
java.io.IOException
javax.servlet.ServletException
org.acegisecurity.AuthenticationException

negotiate

protected jcifs.smb.NtlmPasswordAuthentication negotiate(javax.servlet.http.HttpServletRequest req,
                                                         javax.servlet.http.HttpServletResponse resp,
                                                         boolean skipAuthentication)
                                                  throws java.io.IOException,
                                                         javax.servlet.ServletException
Negotiate password hashes with MSIE clients using NTLM SSP

Parameters:
req - The servlet request
resp - The servlet response
skipAuthentication - If true the negotiation is only done if it is initiated by the client (MSIE post requests after successful NTLM SSP authentication). If false and the user has not been authenticated yet the client will be forced to send an authentication (server sends HttpServletResponse.SC_UNAUTHORIZED).
Returns:
True if the negotiation is complete, otherwise false
Throws:
java.io.IOException
javax.servlet.ServletException

getDefaultDomain

public java.lang.String getDefaultDomain()

setDefaultDomain

public void setDefaultDomain(java.lang.String defaultDomain)

getDomainController

public java.lang.String getDomainController()

setDomainController

public void setDomainController(java.lang.String domainController)

isLoadBalance

public boolean isLoadBalance()

setLoadBalance

public void setLoadBalance(boolean loadBalance)

isEnableBasic

public boolean isEnableBasic()

setEnableBasic

public void setEnableBasic(boolean enableBasic)

isInsecureBasic

public boolean isInsecureBasic()

setInsecureBasic

public void setInsecureBasic(boolean insecureBasic)

getRealm

public java.lang.String getRealm()

setRealm

public void setRealm(java.lang.String realm)

getProperties

public java.util.Properties getProperties()

setProperties

public void setProperties(java.util.Properties properties)

isAlwaysUseDefaultTargetUrl

public boolean isAlwaysUseDefaultTargetUrl()

onPreAuthentication

protected void onPreAuthentication(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)
                            throws org.acegisecurity.AuthenticationException,
                                   java.io.IOException
Throws:
org.acegisecurity.AuthenticationException
java.io.IOException

onSuccessfulAuthentication

protected void onSuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          org.acegisecurity.Authentication authResult)
                                   throws java.io.IOException
Throws:
java.io.IOException

onUnsuccessfulAuthentication

protected void onUnsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            org.acegisecurity.AuthenticationException failed)
                                     throws java.io.IOException
Throws:
java.io.IOException

setAlwaysUseDefaultTargetUrl

public void setAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl)

setApplicationEventPublisher

public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher)
Specified by:
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware

setAuthenticationDetailsSource

public void setAuthenticationDetailsSource(org.acegisecurity.ui.AuthenticationDetailsSource authenticationDetailsSource)

setDefaultTargetUrl

public void setDefaultTargetUrl(java.lang.String defaultTargetUrl)

setExceptionMappings

public void setExceptionMappings(java.util.Properties exceptionMappings)

setMessageSource

public void setMessageSource(org.springframework.context.MessageSource messageSource)
Specified by:
setMessageSource in interface org.springframework.context.MessageSourceAware
Overrides:
setMessageSource in class org.acegisecurity.providers.ldap.authenticator.AbstractLdapAuthenticator

setRememberMeServices

public void setRememberMeServices(org.acegisecurity.ui.rememberme.RememberMeServices rememberMeServices)

successfulAuthentication

protected void successfulAuthentication(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        org.acegisecurity.Authentication authResult)
                                 throws java.io.IOException
Throws:
java.io.IOException

determineTargetUrl

protected java.lang.String determineTargetUrl(javax.servlet.http.HttpServletRequest request)

unsuccessfulAuthentication

protected void unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          org.acegisecurity.AuthenticationException failed)
                                   throws java.io.IOException
Throws:
java.io.IOException

getAuthenticationDetailsSource

public org.acegisecurity.ui.AuthenticationDetailsSource getAuthenticationDetailsSource()

setDetails

protected void setDetails(javax.servlet.http.HttpServletRequest request,
                          org.acegisecurity.providers.UsernamePasswordAuthenticationToken authRequest)
Provided so that subclasses may configure what is put into the authentication request's details property.

Parameters:
request - that an authentication request is being created for
authRequest - the authentication request object that should have its details set

getSkipNtlmAuthUrls

public java.util.List<java.lang.String> getSkipNtlmAuthUrls()

setSkipNtlmAuthUrls

public void setSkipNtlmAuthUrls(java.util.List<java.lang.String> skipNtlmAuthUrls)

getLdapAuthoritiesPopulator

public org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator getLdapAuthoritiesPopulator()

setLdapAuthoritiesPopulator

public void setLdapAuthoritiesPopulator(org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator ldapAuthoritiesPopulator)


Copyright © 2007. All Rights Reserved.