public abstract class ConfigurablePasswordProvider extends Object implements PasswordProvider, PasswordUtility, org.springframework.context.ApplicationContextAware
PasswordProvider
implementations, providing
configuration for default behaviors. There is no need for a subclass to
use this implementation.SecuritySystem
,
Permissions
Modifier and Type | Field and Description |
---|---|
protected OmeroContext |
ctx |
protected String |
hash
Hash implementation to use for encoding passwords to check and changed
passwords.
|
protected boolean |
ignoreUnknown
If true, this implementation should return a null on
#checkPassword(String, String) if the user is unknown, otherwise
a Boolean.FALSE . |
protected PasswordUtil |
legacyUtil
Possibly null
PasswordUtil instance which will be used as a
fallback for password checks if the util instance fails. |
protected org.slf4j.Logger |
log |
protected boolean |
salt
Whether or not salting based on the user ID should be attempted.
|
protected PasswordUtil |
util |
Constructor and Description |
---|
ConfigurablePasswordProvider(PasswordUtil util)
Call
ConfigurablePasswordProvider(PasswordUtil, boolean)
with "ignoreUnknown" equal to false. |
ConfigurablePasswordProvider(PasswordUtil util,
boolean ignoreUnknown)
Call
ConfigurablePasswordProvider(PasswordUtil, boolean, boolean)
with "salt" equal to false. |
ConfigurablePasswordProvider(PasswordUtil util,
boolean ignoreUnknown,
boolean salt) |
Modifier and Type | Method and Description |
---|---|
void |
changePassword(String user,
String password)
Throws by default.
|
Boolean |
checkPassword(String user,
String password,
boolean readOnly)
If
ignoreUnknown is true, returns null, since the base class
knows no users. |
Boolean |
comparePasswords(Long userId,
String trusted,
String provided)
Compares the password provided by the user (unhashed) against the given
trusted password.
|
protected boolean |
comparePasswords(Long userId,
String trusted,
String provided,
PasswordUtil util) |
Boolean |
comparePasswords(String trusted,
String provided)
Compares the password provided by the user (unhashed) against the given
trusted password.
|
protected String |
encodePassword(Long userId,
String newPassword,
boolean salt,
PasswordUtil util) |
String |
encodePassword(String newPassword)
Encodes the password as it would be encoded for a check by
comparePasswords(String, String) |
String |
encodeSaltedPassword(Long userId,
String newPassword)
Encodes the password as it would be encoded for a check by
comparePasswords(String, String) salting the password
with the given userId if it's provided. |
boolean |
hasPassword(String user)
Always returns false, override with specific logic.
|
protected Boolean |
loginAttempt(String user,
Boolean success) |
void |
setApplicationContext(org.springframework.context.ApplicationContext ctx)
Set the ApplicationContext that this object runs in.
|
void |
setLegacyUtil(PasswordUtil legacy) |
protected final org.slf4j.Logger log
protected final String hash
protected final boolean salt
protected final boolean ignoreUnknown
#checkPassword(String, String)
if the user is unknown, otherwise
a Boolean.FALSE
. Default value: falseprotected final PasswordUtil util
protected PasswordUtil legacyUtil
PasswordUtil
instance which will be used as a
fallback for password checks if the util
instance fails.protected OmeroContext ctx
public ConfigurablePasswordProvider(PasswordUtil util)
ConfigurablePasswordProvider(PasswordUtil, boolean)
with "ignoreUnknown" equal to false.util
- public ConfigurablePasswordProvider(PasswordUtil util, boolean ignoreUnknown)
ConfigurablePasswordProvider(PasswordUtil, boolean, boolean)
with "salt" equal to false.public ConfigurablePasswordProvider(PasswordUtil util, boolean ignoreUnknown, boolean salt)
public void setApplicationContext(org.springframework.context.ApplicationContext ctx) throws org.springframework.beans.BeansException
org.springframework.context.ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
ctx
- the ApplicationContext object to be used by this objectorg.springframework.context.ApplicationContextException
- in case of context initialization errorsorg.springframework.beans.BeansException
- if thrown by application context methodsBeanInitializationException
public void setLegacyUtil(PasswordUtil legacy)
public boolean hasPassword(String user)
hasPassword
in interface PasswordProvider
public Boolean checkPassword(String user, String password, boolean readOnly)
ignoreUnknown
is true, returns null, since the base class
knows no users. Otherwise, return Boolean.FALSE
specifying that
authentication should fail.checkPassword
in interface PasswordProvider
public void changePassword(String user, String password) throws PasswordChangeException
changePassword
in interface PasswordProvider
PasswordChangeException
public String encodePassword(String newPassword)
comparePasswords(String, String)
encodePassword
in interface PasswordUtility
public String encodeSaltedPassword(Long userId, String newPassword)
comparePasswords(String, String)
salting the password
with the given userId if it's provided.protected String encodePassword(Long userId, String newPassword, boolean salt, PasswordUtil util)
public Boolean comparePasswords(String trusted, String provided)
checkPassword(String, String, boolean)
.
For this implementation, if the trusted password is null, return
Boolean.FALSE
. If the trusted password is empty (only
whitespace), return Boolean.TRUE
. Otherwise return the results of
String.equals(Object)
.comparePasswords
in interface PasswordUtility
public Boolean comparePasswords(Long userId, String trusted, String provided)
Boolean.FALSE
. If the trusted password is empty (only
whitespace), return Boolean.TRUE
. Otherwise return the results of
String.equals(Object)
.
If legacyUtil
is non-null, and util
returnprotected boolean comparePasswords(Long userId, String trusted, String provided, PasswordUtil util)
Version: 5.1.4-ice35-b55
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.