public class

JdbcTokenRepositoryImpl

extends JdbcDaoSupport
implements PersistentTokenRepository
java.lang.Object
   ↳ org.springframework.dao.support.DaoSupport
     ↳ org.springframework.jdbc.core.support.JdbcDaoSupport
       ↳ org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl

Class Overview

JDBC based persistent login token repository implementation.

Summary

Constants
String CREATE_TABLE_SQL Default SQL for creating the database table to store the tokens
String DEF_INSERT_TOKEN_SQL The default SQL used by createNewToken
String DEF_REMOVE_USER_TOKENS_SQL The default SQL used by removeUserTokens
String DEF_TOKEN_BY_SERIES_SQL The default SQL used by the getTokenBySeries query
String DEF_UPDATE_TOKEN_SQL The default SQL used by updateToken
[Expand]
Inherited Fields
From class org.springframework.dao.support.DaoSupport
Public Constructors
JdbcTokenRepositoryImpl()
Public Methods
void createNewToken(PersistentRememberMeToken token)
PersistentRememberMeToken getTokenForSeries(String seriesId)
Loads the token data for the supplied series identifier.
void removeUserTokens(String username)
void setCreateTableOnStartup(boolean createTableOnStartup)
Intended for convenience in debugging.
void updateToken(String series, String tokenValue, Date lastUsed)
Protected Methods
void initDao()
[Expand]
Inherited Methods
From class org.springframework.jdbc.core.support.JdbcDaoSupport
From class org.springframework.dao.support.DaoSupport
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.security.web.authentication.rememberme.PersistentTokenRepository

Constants

public static final String CREATE_TABLE_SQL

Default SQL for creating the database table to store the tokens

Constant Value: "create table persistent_logins (username varchar(64) not null, series varchar(64) primary key, token varchar(64) not null, last_used timestamp not null)"

public static final String DEF_INSERT_TOKEN_SQL

The default SQL used by createNewToken

Constant Value: "insert into persistent_logins (username, series, token, last_used) values(?,?,?,?)"

public static final String DEF_REMOVE_USER_TOKENS_SQL

The default SQL used by removeUserTokens

Constant Value: "delete from persistent_logins where username = ?"

public static final String DEF_TOKEN_BY_SERIES_SQL

The default SQL used by the getTokenBySeries query

Constant Value: "select username,series,token,last_used from persistent_logins where series = ?"

public static final String DEF_UPDATE_TOKEN_SQL

The default SQL used by updateToken

Constant Value: "update persistent_logins set token = ?, last_used = ? where series = ?"

Public Constructors

public JdbcTokenRepositoryImpl ()

Public Methods

public void createNewToken (PersistentRememberMeToken token)

public PersistentRememberMeToken getTokenForSeries (String seriesId)

Loads the token data for the supplied series identifier. If an error occurs, it will be reported and null will be returned (since the result should just be a failed persistent login).

Returns
  • the token matching the series, or null if no match found or an exception occurred.

public void removeUserTokens (String username)

public void setCreateTableOnStartup (boolean createTableOnStartup)

Intended for convenience in debugging. Will create the persistent_tokens database table when the class is initialized during the initDao method.

Parameters
createTableOnStartup set to true to execute the

public void updateToken (String series, String tokenValue, Date lastUsed)

Protected Methods

protected void initDao ()