public class DefaultValuesAuthenticationSourceDecorator extends Object implements AuthenticationSource, InitializingBean
AcegiAuthenticationSource
if users are to be
allowed to read some information even though they are not logged in.
Note: The defaultUser
should be an non-privileged
user. This is important as this is the one that will be used when no user is
logged in (i.e. empty principal is returned from the target
AuthenticationSource).
Constructor and Description |
---|
DefaultValuesAuthenticationSourceDecorator()
Constructor for bean usage.
|
DefaultValuesAuthenticationSourceDecorator(AuthenticationSource target,
String defaultUser,
String defaultPassword)
Constructor to setup instance directly.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
String |
getCredentials()
Checks if the target's principal is not empty; if not, the credentials
from the target is returned - otherwise return the
defaultPassword . |
String |
getPrincipal()
Checks if the target's principal is not empty; if not, this is returned -
otherwise return the
defaultPassword . |
void |
setDefaultPassword(String defaultPassword)
Set the password of the default user.
|
void |
setDefaultUser(String defaultUser)
Set the default user DN.
|
void |
setTarget(AuthenticationSource target)
Set the target AuthenticationSource.
|
public DefaultValuesAuthenticationSourceDecorator()
public DefaultValuesAuthenticationSourceDecorator(AuthenticationSource target, String defaultUser, String defaultPassword)
target
- the target AuthenticationSource.defaultUser
- dn of the user to use when the target returns an empty
principal.defaultPassword
- password of the user to use when the target returns an empty
principal.public String getCredentials()
defaultPassword
.getCredentials
in interface AuthenticationSource
defaultPassword
otherwise.public String getPrincipal()
defaultPassword
.getPrincipal
in interface AuthenticationSource
defaultPassword
otherwise.public void setDefaultPassword(String defaultPassword)
defaultPassword
- the password of the default user.public void setDefaultUser(String defaultUser)
defaultUser
- DN of the default user.public void setTarget(AuthenticationSource target)
target
- the target AuthenticationSource.public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception