JSecurity

org.jsecurity.web
Class WebRememberMeManager

java.lang.Object
  extended by org.jsecurity.subject.AbstractRememberMeManager
      extended by org.jsecurity.web.WebRememberMeManager
All Implemented Interfaces:
RememberMeManager

public class WebRememberMeManager
extends AbstractRememberMeManager

Remembers a Subject's identity by using a WebAttribute instance to retain the identity value between web requests.

This class's default WebAttribute instance is a CookieAttribute, storing the Subject's principals in a Cookie. Note that because this class subclasses the AbstractRememberMeManager which already provides serialization and encryption logic, this class utilizes both for added security before setting the cookie value.

This class also contains "passthrough" JavaBeans-compatible getters/setters for the underlying CookieAttribute's properties to make configuration easier.

Note however as a basic sanity check, these passthrough methods will first assert that the underlying identityAttribute is actually a CookieAttribute. If it is not, an IllegalStateException will be thrown. Because the default instance of this class is already CookieAttribute, you would only ever experience the exception if you explicitly override the internal instance with a different type and accidentally call one of these JavaBeans passthrough methods.

Just be aware of this if you manually override the identityAttribute property to be an instance of something other than a CookieAttribute.

Since:
0.9
Author:
Les Hazlewood

Field Summary
static String DEFAULT_REMEMBER_ME_COOKIE_NAME
          The default name of the underlying rememberMe cookie which is rememberMe.
protected  WebAttribute<String> identityAttribute
           
 
Constructor Summary
WebRememberMeManager()
           
 
Method Summary
protected  void assertCookieAttribute()
           
protected  void forgetIdentity()
           
 int getCookieMaxAge()
          Passthrough JavaBeans property that will get the underyling rememberMe cookie's max age.
 String getCookieName()
          Passthrough JavaBeans property that will get the underyling rememberMe cookie's name.
 String getCookiePath()
          Passthrough JavaBeans property that will get the underyling rememberMe cookie's path.
 WebAttribute<String> getIdentityAttribute()
           
protected  byte[] getSerializedRememberedIdentity()
           
 boolean isCookieSecure()
          Passthrough JavaBeans property that will get the underyling rememberMe cookie's 'secure' status.
protected  void rememberSerializedIdentity(byte[] serialized)
           
 void setCookieMaxAge(int maxAge)
          Passthrough JavaBeans property that will get the underyling rememberMe cookie's max age.
 void setCookieName(String name)
          Passthrough JavaBeans property that will set the underyling rememberMe cookie's name.
 void setCookiePath(String path)
          Passthrough JavaBeans property that will set the underyling rememberMe cookie's path.
 void setCookieSecure(boolean secure)
          Passthrough JavaBeans property that will set the underyling rememberMe cookie's 'secure' status.
 void setIdentityAttribute(WebAttribute<String> identityAttribute)
           
 
Methods inherited from class org.jsecurity.subject.AbstractRememberMeManager
decrypt, deserialize, encrypt, forgetIdentity, forgetIdentity, getCipher, getCipherKey, getDecryptionCipherKey, getEncryptionCipherKey, getIdentityToRemember, getRememberedPrincipals, getSerializer, isRememberMe, onFailedLogin, onLogout, onRememberedPrincipalFailure, onSuccessfulLogin, rememberIdentity, rememberIdentity, rememberIdentity, serialize, setCipher, setCipherKey, setCipherKeyBase64, setCipherKeyHex, setDecryptionCipherKey, setDecryptionCipherKeyBase64, setDecryptionCipherKeyHex, setEncryptionCipherKey, setEncryptionCipherKeyBase64, setEncryptionCipherKeyHex, setSerializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REMEMBER_ME_COOKIE_NAME

public static final String DEFAULT_REMEMBER_ME_COOKIE_NAME
The default name of the underlying rememberMe cookie which is rememberMe.

See Also:
Constant Field Values

identityAttribute

protected WebAttribute<String> identityAttribute
Constructor Detail

WebRememberMeManager

public WebRememberMeManager()
Method Detail

getIdentityAttribute

public WebAttribute<String> getIdentityAttribute()

setIdentityAttribute

public void setIdentityAttribute(WebAttribute<String> identityAttribute)

assertCookieAttribute

protected void assertCookieAttribute()

getCookieName

public String getCookieName()
Passthrough JavaBeans property that will get the underyling rememberMe cookie's name.

The default value is DEFAULT_REMEMBER_ME_COOKIE_NAME

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Returns:
the underlying rememberMe cookie's name

setCookieName

public void setCookieName(String name)
Passthrough JavaBeans property that will set the underyling rememberMe cookie's name.

The default value is DEFAULT_REMEMBER_ME_COOKIE_NAME

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Parameters:
name - the name to assign to the underlying rememberMe cookie

getCookiePath

public String getCookiePath()
Passthrough JavaBeans property that will get the underyling rememberMe cookie's path.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Returns:
the underlying rememberMe cookie's path

setCookiePath

public void setCookiePath(String path)
Passthrough JavaBeans property that will set the underyling rememberMe cookie's path.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Parameters:
path - the path to assign to the underlying rememberMe cookie

getCookieMaxAge

public int getCookieMaxAge()
Passthrough JavaBeans property that will get the underyling rememberMe cookie's max age.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Returns:
the underlying rememberMe cookie's max age.

setCookieMaxAge

public void setCookieMaxAge(int maxAge)
Passthrough JavaBeans property that will get the underyling rememberMe cookie's max age.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Parameters:
maxAge - the max age to assign to the underlying rememberMe cookie

isCookieSecure

public boolean isCookieSecure()
Passthrough JavaBeans property that will get the underyling rememberMe cookie's 'secure' status.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Returns:
the underlying rememberMe cookie's 'secure' flag

setCookieSecure

public void setCookieSecure(boolean secure)
Passthrough JavaBeans property that will set the underyling rememberMe cookie's 'secure' status.

This method performs a quick CookieAttribute sanity check as described in the class-level JavaDoc.

Parameters:
secure - the 'secure' flag to assign to the underlying rememberMe cookie.

rememberSerializedIdentity

protected void rememberSerializedIdentity(byte[] serialized)
Specified by:
rememberSerializedIdentity in class AbstractRememberMeManager

getSerializedRememberedIdentity

protected byte[] getSerializedRememberedIdentity()
Specified by:
getSerializedRememberedIdentity in class AbstractRememberMeManager

forgetIdentity

protected void forgetIdentity()
Specified by:
forgetIdentity in class AbstractRememberMeManager

JSecurity

Copyright © 2004-2008 JSecurity.