Java Doc for TokenBasedRememberMeServices.java in  » Security » acegi-security » org » acegisecurity » ui » rememberme » 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.ui.rememberme 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices

TokenBasedRememberMeServices
public class TokenBasedRememberMeServices implements RememberMeServices,InitializingBean,LogoutHandler(Code)
Identifies previously remembered users by a Base-64 encoded cookie.

This implementation does not rely on an external database, so is attractive for simple applications. The cookie will be valid for a specific period from the date of the last TokenBasedRememberMeServices.loginSuccess(HttpServletRequest,HttpServletResponse,Authentication) . As per the interface contract, this method will only be called when the principal completes a successful interactive authentication. As such the time period commences from the last authentication attempt where they furnished credentials - not the time period they last logged in via remember-me. The implementation will only send a remember-me token if the parameter defined by TokenBasedRememberMeServices.setParameter(String) is present.

An org.acegisecurity.userdetails.UserDetailsService is required by this implementation, so that it can construct a valid Authentication from the returned org.acegisecurity.userdetails.UserDetails . This is also necessary so that the user's password is available and can be checked as part of the encoded cookie.

The cookie encoded by this implementation adopts the following form:

 username + ":" + expiryTime + ":" + Md5Hex(username + ":" + expiryTime + ":" + password + ":" + key)
 

As such, if the user changes their password any remember-me token will be invalidated. Equally, the system administrator may invalidate every remember-me token on issue by changing the key. This provides some reasonable approaches to recovering from a remember-me token being left on a public machine (eg kiosk system, Internet cafe etc). Most importantly, at no time is the user's password ever sent to the user agent, providing an important security safeguard. Unfortunately the username is necessary in this implementation (as we do not want to rely on a database for remember-me services) and as such high security applications should be aware of this occasionally undesired disclosure of a valid username.

This is a basic remember-me implementation which is suitable for many applications. However, we recommend a database-based implementation if you require a more secure remember-me approach.

By default the tokens will be valid for 14 days from the last successful authentication attempt. This can be changed using TokenBasedRememberMeServices.setTokenValiditySeconds(long) .


author:
   Ben Alex
version:
   $Id: TokenBasedRememberMeServices.java 1871 2007-05-25 03:12:49Z
version:
   benalex $


Field Summary
final public static  StringACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY
    
final public static  StringDEFAULT_PARAMETER
    
protected  AuthenticationDetailsSourceauthenticationDetailsSource
    
final protected static  Loglogger
    
protected  longtokenValiditySeconds
    


Method Summary
public  voidafterPropertiesSet()
    
public  AuthenticationautoLogin(HttpServletRequest request, HttpServletResponse response)
    
protected  voidcancelCookie(HttpServletRequest request, HttpServletResponse response, String reasonForLog)
    
public  StringgetCookieName()
    
public  StringgetKey()
    
public  StringgetParameter()
    
public  longgetTokenValiditySeconds()
    
public  UserDetailsServicegetUserDetailsService()
    
public  booleanisAlwaysRemember()
    
protected  booleanisTokenExpired(long tokenExpiryTime)
    
protected  booleanisValidUserDetails(HttpServletRequest request, HttpServletResponse response, UserDetails userDetails, String[] cookieTokens)
    
protected  UserDetailsloadUserDetails(HttpServletRequest request, HttpServletResponse response, String[] cookieTokens)
    
public  voidloginFail(HttpServletRequest request, HttpServletResponse response)
    
public  voidloginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication successfulAuthentication)
    
public  voidlogout(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
    
protected  CookiemakeCancelCookie(HttpServletRequest request)
    
protected  StringmakeTokenSignature(long tokenExpiryTime, UserDetails userDetails)
    
protected  CookiemakeValidCookie(String tokenValueBase64, HttpServletRequest request, long maxAge)
    
protected  booleanrememberMeRequested(HttpServletRequest request, String parameter)
    
protected  StringretrievePassword(Authentication successfulAuthentication)
    
protected  StringretrieveUserName(Authentication successfulAuthentication)
    
public  voidsetAlwaysRemember(boolean alwaysRemember)
    
public  voidsetAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource)
    
public  voidsetCookieName(String cookieName)
    
public  voidsetKey(String key)
    
public  voidsetParameter(String parameter)
    
public  voidsetTokenValiditySeconds(long tokenValiditySeconds)
    
public  voidsetUserDetailsService(UserDetailsService userDetailsService)
    

Field Detail
ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY
final public static String ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY(Code)



DEFAULT_PARAMETER
final public static String DEFAULT_PARAMETER(Code)



authenticationDetailsSource
protected AuthenticationDetailsSource authenticationDetailsSource(Code)



logger
final protected static Log logger(Code)



tokenValiditySeconds
protected long tokenValiditySeconds(Code)





Method Detail
afterPropertiesSet
public void afterPropertiesSet() throws Exception(Code)



autoLogin
public Authentication autoLogin(HttpServletRequest request, HttpServletResponse response)(Code)



cancelCookie
protected void cancelCookie(HttpServletRequest request, HttpServletResponse response, String reasonForLog)(Code)



getCookieName
public String getCookieName()(Code)



getKey
public String getKey()(Code)



getParameter
public String getParameter()(Code)



getTokenValiditySeconds
public long getTokenValiditySeconds()(Code)



getUserDetailsService
public UserDetailsService getUserDetailsService()(Code)



isAlwaysRemember
public boolean isAlwaysRemember()(Code)



isTokenExpired
protected boolean isTokenExpired(long tokenExpiryTime)(Code)



isValidUserDetails
protected boolean isValidUserDetails(HttpServletRequest request, HttpServletResponse response, UserDetails userDetails, String[] cookieTokens)(Code)



loadUserDetails
protected UserDetails loadUserDetails(HttpServletRequest request, HttpServletResponse response, String[] cookieTokens)(Code)



loginFail
public void loginFail(HttpServletRequest request, HttpServletResponse response)(Code)



loginSuccess
public void loginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication successfulAuthentication)(Code)



logout
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication)(Code)



makeCancelCookie
protected Cookie makeCancelCookie(HttpServletRequest request)(Code)



makeTokenSignature
protected String makeTokenSignature(long tokenExpiryTime, UserDetails userDetails)(Code)

Parameters:
  tokenExpiryTime -
Parameters:
  userDetails -



makeValidCookie
protected Cookie makeValidCookie(String tokenValueBase64, HttpServletRequest request, long maxAge)(Code)



rememberMeRequested
protected boolean rememberMeRequested(HttpServletRequest request, String parameter)(Code)



retrievePassword
protected String retrievePassword(Authentication successfulAuthentication)(Code)



retrieveUserName
protected String retrieveUserName(Authentication successfulAuthentication)(Code)



setAlwaysRemember
public void setAlwaysRemember(boolean alwaysRemember)(Code)



setAuthenticationDetailsSource
public void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource)(Code)



setCookieName
public void setCookieName(String cookieName)(Code)



setKey
public void setKey(String key)(Code)



setParameter
public void setParameter(String parameter)(Code)



setTokenValiditySeconds
public void setTokenValiditySeconds(long tokenValiditySeconds)(Code)



setUserDetailsService
public void setUserDetailsService(UserDetailsService userDetailsService)(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.