Java Doc for AbstractUserDetailsAuthenticationProvider.java in  » Security » acegi-security » org » acegisecurity » providers » dao » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Security » acegi security » org.acegisecurity.providers.dao 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider

All known Subclasses:   org.acegisecurity.providers.siteminder.SiteminderAuthenticationProvider,  org.acegisecurity.providers.ldap.LdapAuthenticationProvider,  org.acegisecurity.providers.dao.DaoAuthenticationProvider,
AbstractUserDetailsAuthenticationProvider
abstract public class AbstractUserDetailsAuthenticationProvider implements AuthenticationProvider,InitializingBean,MessageSourceAware(Code)
A base AuthenticationProvider that allows subclasses to override and work with org.acegisecurity.userdetails.UserDetails objects. The class is designed to respond to UsernamePasswordAuthenticationToken authentication requests.

Upon successful validation, a UsernamePasswordAuthenticationToken will be created and returned to the caller. The token will include as its principal either a String representation of the username, or the UserDetails that was returned from the authentication repository. Using String is appropriate if a container adapter is being used, as it expects String representations of the username. Using UserDetails is appropriate if you require access to additional properties of the authenticated user, such as email addresses, human-friendly names etc. As container adapters are not recommended to be used, and UserDetails implementations provide additional flexibility, by default a UserDetails is returned. To override this default, set the AbstractUserDetailsAuthenticationProvider.setForcePrincipalAsString to true.

Caching is handled via the UserDetails object being placed in the UserCache . This ensures that subsequent requests with the same username can be validated without needing to query the UserDetailsService . It should be noted that if a user appears to present an incorrect password, the UserDetailsService will be queried to confirm the most up-to-date password was used for comparison.


author:
   Ben Alex
version:
   $Id: AbstractUserDetailsAuthenticationProvider.java 1784 2007-02-24 21:00:24Z luke_t $


Field Summary
protected  booleanhideUserNotFoundExceptions
    
protected  MessageSourceAccessormessages
    


Method Summary
abstract protected  voidadditionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication)
     Allows subclasses to perform any additional checks of a returned (or cached) UserDetails for a given authentication request.
final public  voidafterPropertiesSet()
    
public  Authenticationauthenticate(Authentication authentication)
    
protected  AuthenticationcreateSuccessAuthentication(Object principal, Authentication authentication, UserDetails user)
    
protected  voiddoAfterPropertiesSet()
    
public  UserCachegetUserCache()
    
public  booleanisForcePrincipalAsString()
    
public  booleanisHideUserNotFoundExceptions()
    
abstract protected  UserDetailsretrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
     Allows subclasses to actually retrieve the UserDetails from an implementation-specific location, with the option of throwing an AuthenticationException immediately if the presented credentials are incorrect (this is especially useful if it is necessary to bind to a resource as the user in order to obtain or generate a UserDetails).

Subclasses are not required to perform any caching, as the AbstractUserDetailsAuthenticationProvider will by default cache the UserDetails.

public  voidsetForcePrincipalAsString(boolean forcePrincipalAsString)
    
public  voidsetHideUserNotFoundExceptions(boolean hideUserNotFoundExceptions)
     By default the AbstractUserDetailsAuthenticationProvider throws a BadCredentialsException if a username is not found or the password is incorrect.
public  voidsetMessageSource(MessageSource messageSource)
    
public  voidsetUserCache(UserCache userCache)
    
public  booleansupports(Class authentication)
    

Field Detail
hideUserNotFoundExceptions
protected boolean hideUserNotFoundExceptions(Code)



messages
protected MessageSourceAccessor messages(Code)





Method Detail
additionalAuthenticationChecks
abstract protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)
Allows subclasses to perform any additional checks of a returned (or cached) UserDetails for a given authentication request. Generally a subclass will at least compare the Authentication.getCredentials with a UserDetails.getPassword . If custom logic is needed to compare additional properties of UserDetails and/or UsernamePasswordAuthenticationToken, these should also appear in this method.
Parameters:
  userDetails - as retrieved from the AbstractUserDetailsAuthenticationProvider.retrieveUser(String,UsernamePasswordAuthenticationToken) orUserCache
Parameters:
  authentication - the current request that needs to be authenticated
throws:
  AuthenticationException - AuthenticationException if the credentials could not be validated (generally aBadCredentialsException, an AuthenticationServiceException)



afterPropertiesSet
final public void afterPropertiesSet() throws Exception(Code)



authenticate
public Authentication authenticate(Authentication authentication) throws AuthenticationException(Code)



createSuccessAuthentication
protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user)(Code)
Creates a successful Authentication object.

Protected so subclasses can override.

Subclasses will usually store the original credentials the user supplied (not salted or encoded passwords) in the returned Authentication object.


Parameters:
  principal - that should be the principal in the returned object (defined by the AbstractUserDetailsAuthenticationProvider.isForcePrincipalAsString() method)
Parameters:
  authentication - that was presented to the provider for validation
Parameters:
  user - that was loaded by the implementation the successful authentication token



doAfterPropertiesSet
protected void doAfterPropertiesSet() throws Exception(Code)



getUserCache
public UserCache getUserCache()(Code)



isForcePrincipalAsString
public boolean isForcePrincipalAsString()(Code)



isHideUserNotFoundExceptions
public boolean isHideUserNotFoundExceptions()(Code)



retrieveUser
abstract protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)
Allows subclasses to actually retrieve the UserDetails from an implementation-specific location, with the option of throwing an AuthenticationException immediately if the presented credentials are incorrect (this is especially useful if it is necessary to bind to a resource as the user in order to obtain or generate a UserDetails).

Subclasses are not required to perform any caching, as the AbstractUserDetailsAuthenticationProvider will by default cache the UserDetails. The caching of UserDetails does present additional complexity as this means subsequent requests that rely on the cache will need to still have their credentials validated, even if the correctness of credentials was assured by subclasses adopting a binding-based strategy in this method. Accordingly it is important that subclasses either disable caching (if they want to ensure that this method is the only method that is capable of authenticating a request, as no UserDetails will ever be cached) or ensure subclasses implement AbstractUserDetailsAuthenticationProvider.additionalAuthenticationChecks(UserDetails,UsernamePasswordAuthenticationToken) to compare the credentials of a cached UserDetails with subsequent authentication requests.

Most of the time subclasses will not perform credentials inspection in this method, instead performing it in AbstractUserDetailsAuthenticationProvider.additionalAuthenticationChecks(UserDetails,UsernamePasswordAuthenticationToken) so that code related to credentials validation need not be duplicated across two methods.


Parameters:
  username - The username to retrieve
Parameters:
  authentication - The authentication request, which subclasses may need to perform a binding-basedretrieval of the UserDetails the user information (never null - instead an exception should the thrown)
throws:
  AuthenticationException - if the credentials could not be validated (generally aBadCredentialsException, an AuthenticationServiceException orUsernameNotFoundException)



setForcePrincipalAsString
public void setForcePrincipalAsString(boolean forcePrincipalAsString)(Code)



setHideUserNotFoundExceptions
public void setHideUserNotFoundExceptions(boolean hideUserNotFoundExceptions)(Code)
By default the AbstractUserDetailsAuthenticationProvider throws a BadCredentialsException if a username is not found or the password is incorrect. Setting this property to false will cause UsernameNotFoundExceptions to be thrown instead for the former. Note this is considered less secure than throwing BadCredentialsException for both exceptions.
Parameters:
  hideUserNotFoundExceptions - set to false if you wish UsernameNotFoundExceptionsto be thrown instead of the non-specific BadCredentialsException (defaults totrue)



setMessageSource
public void setMessageSource(MessageSource messageSource)(Code)



setUserCache
public void setUserCache(UserCache userCache)(Code)



supports
public boolean supports(Class authentication)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.