mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 20:39:18 +00:00
#1481 HashLogin has now a setter to configure the UserStore implementation to use
Signed-off-by: olivier lamy <olamy@webtide.com>
This commit is contained in:
parent
a2f89f2bf9
commit
99a98127cd
@ -49,10 +49,11 @@ public class HashLoginService extends AbstractLoginService
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HashLoginService.class);
|
||||
|
||||
private PropertyUserStore _propertyUserStore;
|
||||
private File _configFile;
|
||||
private Resource _configResource;
|
||||
private boolean hotReload = false; // default is not to reload
|
||||
private UserStore _userStore;
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -139,13 +140,21 @@ public class HashLoginService extends AbstractLoginService
|
||||
this.hotReload = enable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure the {@link UserStore} implementation to use.
|
||||
* If none, for backward compat if none the {@link PropertyUserStore} will be used
|
||||
* @param userStore the {@link UserStore} implementation to use
|
||||
*/
|
||||
public void setUserStore(UserStore userStore)
|
||||
{
|
||||
this._userStore = userStore;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected String[] loadRoleInfo(UserPrincipal user)
|
||||
{
|
||||
UserIdentity id = _propertyUserStore.getUserIdentity(user.getName());
|
||||
UserIdentity id = _userStore.getUserIdentity(user.getName());
|
||||
if (id == null)
|
||||
return null;
|
||||
|
||||
@ -162,13 +171,11 @@ public class HashLoginService extends AbstractLoginService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected UserPrincipal loadUserInfo(String userName)
|
||||
{
|
||||
UserIdentity id = _propertyUserStore.getUserIdentity(userName);
|
||||
UserIdentity id = _userStore.getUserIdentity(userName);
|
||||
if (id != null)
|
||||
{
|
||||
return (UserPrincipal)id.getUserPrincipal();
|
||||
@ -188,15 +195,17 @@ public class HashLoginService extends AbstractLoginService
|
||||
{
|
||||
super.doStart();
|
||||
|
||||
if (_propertyUserStore == null)
|
||||
// can be null so we switch to previous behaviour using PropertyUserStore
|
||||
if (_userStore == null)
|
||||
{
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _configFile + " hotReload: " + hotReload);
|
||||
|
||||
_propertyUserStore = new PropertyUserStore();
|
||||
_propertyUserStore.setHotReload(hotReload);
|
||||
_propertyUserStore.setConfigPath(_configFile);
|
||||
_propertyUserStore.start();
|
||||
PropertyUserStore propertyUserStore = new PropertyUserStore();
|
||||
propertyUserStore.setHotReload(hotReload);
|
||||
propertyUserStore.setConfigPath(_configFile);
|
||||
propertyUserStore.start();
|
||||
this._userStore = propertyUserStore;
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,8 +217,8 @@ public class HashLoginService extends AbstractLoginService
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
if (_propertyUserStore != null)
|
||||
_propertyUserStore.stop();
|
||||
_propertyUserStore = null;
|
||||
if (_userStore != null)
|
||||
_userStore.stop();
|
||||
_userStore = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user