JSecurity

org.jsecurity.subject
Class AbstractRememberMeManager

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

public abstract class AbstractRememberMeManager
extends Object
implements RememberMeManager

Abstract implementation of the RememberMeManager interface that handles serialization and encryption of the remembered user identity.

The remembered identity storage location is implementation-specific.

Since:
0.9
Author:
Les Hazlewood, Jeremy Haile

Constructor Summary
AbstractRememberMeManager()
           
 
Method Summary
protected  byte[] decrypt(byte[] encrypted)
           
protected  PrincipalCollection deserialize(byte[] serializedIdentity)
           
protected  byte[] encrypt(byte[] serialized)
           
protected abstract  void forgetIdentity()
           
protected  void forgetIdentity(AuthenticationToken token)
           
protected  void forgetIdentity(AuthenticationToken token, AuthenticationException ae)
           
 Cipher getCipher()
           
 byte[] getCipherKey()
           
 byte[] getDecryptionCipherKey()
           
 byte[] getEncryptionCipherKey()
           
protected  PrincipalCollection getIdentityToRemember(AuthenticationInfo info)
           
 PrincipalCollection getRememberedPrincipals()
           
protected abstract  byte[] getSerializedRememberedIdentity()
           
 Serializer getSerializer()
           
protected  boolean isRememberMe(AuthenticationToken token)
           
 void onFailedLogin(AuthenticationToken token, AuthenticationException ae)
           
 void onLogout(PrincipalCollection subjectPrincipals)
           
protected  PrincipalCollection onRememberedPrincipalFailure(Exception e)
          Called when an exception is thrown while trying to retrieve principals.
 void onSuccessfulLogin(AuthenticationToken token, AuthenticationInfo info)
           
 void rememberIdentity(AuthenticationInfo successfullyAuthenticated)
           
 void rememberIdentity(AuthenticationToken submittedToken, AuthenticationInfo successfullyAuthenticated)
           
protected  void rememberIdentity(PrincipalCollection accountPrincipals)
           
protected abstract  void rememberSerializedIdentity(byte[] serialized)
           
protected  byte[] serialize(PrincipalCollection principals)
           
 void setCipher(Cipher cipher)
           
 void setCipherKey(byte[] cipherKey)
           
 void setCipherKeyBase64(String base64)
           
 void setCipherKeyHex(String hex)
           
 void setDecryptionCipherKey(byte[] decryptionCipherKey)
           
 void setDecryptionCipherKeyBase64(String base64)
           
 void setDecryptionCipherKeyHex(String hex)
           
 void setEncryptionCipherKey(byte[] encryptionCipherKey)
           
 void setEncryptionCipherKeyBase64(String base64)
           
 void setEncryptionCipherKeyHex(String hex)
           
 void setSerializer(Serializer serializer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRememberMeManager

public AbstractRememberMeManager()
Method Detail

getSerializer

public Serializer getSerializer()

setSerializer

public void setSerializer(Serializer serializer)

getCipher

public Cipher getCipher()

setCipher

public void setCipher(Cipher cipher)

getEncryptionCipherKey

public byte[] getEncryptionCipherKey()

setEncryptionCipherKey

public void setEncryptionCipherKey(byte[] encryptionCipherKey)

setEncryptionCipherKeyHex

public void setEncryptionCipherKeyHex(String hex)

setEncryptionCipherKeyBase64

public void setEncryptionCipherKeyBase64(String base64)

getDecryptionCipherKey

public byte[] getDecryptionCipherKey()

setDecryptionCipherKey

public void setDecryptionCipherKey(byte[] decryptionCipherKey)

setDecryptionCipherKeyHex

public void setDecryptionCipherKeyHex(String hex)

setDecryptionCipherKeyBase64

public void setDecryptionCipherKeyBase64(String base64)

getCipherKey

public byte[] getCipherKey()

setCipherKey

public void setCipherKey(byte[] cipherKey)

setCipherKeyHex

public void setCipherKeyHex(String hex)

setCipherKeyBase64

public void setCipherKeyBase64(String base64)

rememberSerializedIdentity

protected abstract void rememberSerializedIdentity(byte[] serialized)

getSerializedRememberedIdentity

protected abstract byte[] getSerializedRememberedIdentity()

forgetIdentity

protected abstract void forgetIdentity()

isRememberMe

protected boolean isRememberMe(AuthenticationToken token)

onSuccessfulLogin

public void onSuccessfulLogin(AuthenticationToken token,
                              AuthenticationInfo info)
Specified by:
onSuccessfulLogin in interface RememberMeManager

rememberIdentity

public void rememberIdentity(AuthenticationToken submittedToken,
                             AuthenticationInfo successfullyAuthenticated)

rememberIdentity

public void rememberIdentity(AuthenticationInfo successfullyAuthenticated)

getIdentityToRemember

protected PrincipalCollection getIdentityToRemember(AuthenticationInfo info)

rememberIdentity

protected void rememberIdentity(PrincipalCollection accountPrincipals)

getRememberedPrincipals

public PrincipalCollection getRememberedPrincipals()
Specified by:
getRememberedPrincipals in interface RememberMeManager

onRememberedPrincipalFailure

protected PrincipalCollection onRememberedPrincipalFailure(Exception e)
Called when an exception is thrown while trying to retrieve principals. The default implementation logs a warning and forgets the problem identity. This most commonly would occur when an encryption key is updated and old principals are retrieved that have been encrypted with the previous key.

Parameters:
e - the exception that was thrown.
Returns:
the principal collection to be returned.

encrypt

protected byte[] encrypt(byte[] serialized)

decrypt

protected byte[] decrypt(byte[] encrypted)

serialize

protected byte[] serialize(PrincipalCollection principals)

deserialize

protected PrincipalCollection deserialize(byte[] serializedIdentity)

onFailedLogin

public void onFailedLogin(AuthenticationToken token,
                          AuthenticationException ae)
Specified by:
onFailedLogin in interface RememberMeManager

onLogout

public void onLogout(PrincipalCollection subjectPrincipals)
Specified by:
onLogout in interface RememberMeManager

forgetIdentity

protected void forgetIdentity(AuthenticationToken token,
                              AuthenticationException ae)

forgetIdentity

protected void forgetIdentity(AuthenticationToken token)

JSecurity

Copyright © 2004-2008 JSecurity.