public class ReflectionSaltSource extends Object implements SaltSource, InitializingBean
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.
Constructor and Description |
---|
ReflectionSaltSource() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Object |
getSalt(UserDetails user)
Performs reflection on the passed
User to obtain the salt. |
protected String |
getUserPropertyToUse() |
void |
setUserPropertyToUse(String userPropertyToUse)
The method name to call to obtain the salt.
|
String |
toString() |
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public Object getSalt(UserDetails user)
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.
getSalt
in interface SaltSource
user
- which contains the method identified by userPropertyToUse
AuthenticationServiceException
- if reflection failsprotected String getUserPropertyToUse()
public void setUserPropertyToUse(String userPropertyToUse)
UserDetails
contains a
UserDetails.getSalt()
method, you should set this property to
"getSalt" or "salt".userPropertyToUse
- the name of the getter to call to obtain the salt
from the UserDetails