Spring Security SAML

org.springframework.security.providers
Class ExpiringUsernameAuthenticationToken

java.lang.Object
  extended by org.springframework.security.authentication.AbstractAuthenticationToken
      extended by org.springframework.security.authentication.UsernamePasswordAuthenticationToken
          extended by org.springframework.security.providers.ExpiringUsernameAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, org.springframework.security.core.Authentication, org.springframework.security.core.CredentialsContainer

public class ExpiringUsernameAuthenticationToken
extends org.springframework.security.authentication.UsernamePasswordAuthenticationToken

Authentication token with capability to disable itself after specific datetime. In case no expiration date is specified for the token functionality is exactly the same as of UsernamePasswordAuthenticationToken.

Author:
Vladimir Schäfer
See Also:
Serialized Form

Constructor Summary
ExpiringUsernameAuthenticationToken(Date tokenExpiration, Object principal, Object credentials, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
          Should only be used by authenticationManager as specified in UsernamePasswordAuthenticationToken.
ExpiringUsernameAuthenticationToken(Object principal, Object credentials)
           
 
Method Summary
 void eraseCredentials()
          SAML credentials can be kept without clearing.
 Date getTokenExpiration()
           
 boolean isAuthenticated()
           
 
Methods inherited from class org.springframework.security.authentication.UsernamePasswordAuthenticationToken
getCredentials, getPrincipal, setAuthenticated
 
Methods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
equals, getAuthorities, getDetails, getName, hashCode, setDetails, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpiringUsernameAuthenticationToken

public ExpiringUsernameAuthenticationToken(Object principal,
                                           Object credentials)
Parameters:
principal - principal
credentials - credential
See Also:
UsernamePasswordAuthenticationToken.UsernamePasswordAuthenticationToken(Object, Object)

ExpiringUsernameAuthenticationToken

public ExpiringUsernameAuthenticationToken(Date tokenExpiration,
                                           Object principal,
                                           Object credentials,
                                           Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
Should only be used by authenticationManager as specified in UsernamePasswordAuthenticationToken. In case the tokenExpiration is not null the calls to the isAuthenticated method will return false after the current time is beyond the tokenExpiration. No functionality is changed when tokenExpiration is null.

Parameters:
tokenExpiration - null or date after which the token is not valid anymore
principal - principal
credentials - credentials
authorities - authorities
Method Detail

isAuthenticated

public boolean isAuthenticated()
Specified by:
isAuthenticated in interface org.springframework.security.core.Authentication
Overrides:
isAuthenticated in class org.springframework.security.authentication.AbstractAuthenticationToken
Returns:
true in case the token is authenticated (determined by constructor call) and tokenExpiration is either null or the expiration time is on or after current time.

getTokenExpiration

public Date getTokenExpiration()
Returns:
null if no expiration is set, expiration date otherwise

eraseCredentials

public void eraseCredentials()
SAML credentials can be kept without clearing.

Specified by:
eraseCredentials in interface org.springframework.security.core.CredentialsContainer
Overrides:
eraseCredentials in class org.springframework.security.authentication.UsernamePasswordAuthenticationToken

Spring Security SAML