public class

ReflectionSaltSource

extends Object
implements InitializingBean SaltSource
java.lang.Object
   ↳ org.springframework.security.authentication.dao.ReflectionSaltSource

Class Overview

Obtains a salt from a specified property of the User object.

This allows you to subclass User and provide an additional bean getter for a salt. You should use a synthetic value that does not change, such as a database primary key. Do not use username if it is likely to change.

Summary

Public Constructors
ReflectionSaltSource()
Public Methods
void afterPropertiesSet()
Object getSalt(UserDetails user)
Performs reflection on the passed User to obtain the salt.
void setUserPropertyToUse(String userPropertyToUse)
The method name to call to obtain the salt.
String toString()
Protected Methods
String getUserPropertyToUse()
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.security.authentication.dao.SaltSource

Public Constructors

public ReflectionSaltSource ()

Public Methods

public void afterPropertiesSet ()

Throws
Exception

public Object getSalt (UserDetails user)

Performs reflection on the passed User to obtain the salt.

The property identified by userPropertyToUse must be available from the passed User object. If it is not available, an AuthenticationServiceException will be thrown.

Parameters
user which contains the method identified by userPropertyToUse
Returns
  • the result of invoking user.userPropertyToUse(), or if the method doesn't exist, user.getUserPropertyToUse().
Throws
AuthenticationServiceException if reflection fails

public void setUserPropertyToUse (String userPropertyToUse)

The method name to call to obtain the salt. Can be either a method name or a bean property name. If your UserDetails contains a UserDetails.getSalt() method, you should set this property to "getSalt" or "salt".

Parameters
userPropertyToUse the name of the getter to call to obtain the salt from the UserDetails

public String toString ()

Protected Methods

protected String getUserPropertyToUse ()