mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-04 04:49:12 +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 static final Logger LOG = Log.getLogger(HashLoginService.class);
|
||||||
|
|
||||||
private PropertyUserStore _propertyUserStore;
|
|
||||||
private File _configFile;
|
private File _configFile;
|
||||||
private Resource _configResource;
|
private Resource _configResource;
|
||||||
private boolean hotReload = false; // default is not to reload
|
private boolean hotReload = false; // default is not to reload
|
||||||
|
private UserStore _userStore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@ -139,13 +140,21 @@ public class HashLoginService extends AbstractLoginService
|
|||||||
this.hotReload = enable;
|
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
|
@Override
|
||||||
protected String[] loadRoleInfo(UserPrincipal user)
|
protected String[] loadRoleInfo(UserPrincipal user)
|
||||||
{
|
{
|
||||||
UserIdentity id = _propertyUserStore.getUserIdentity(user.getName());
|
UserIdentity id = _userStore.getUserIdentity(user.getName());
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -162,13 +171,11 @@ public class HashLoginService extends AbstractLoginService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected UserPrincipal loadUserInfo(String userName)
|
protected UserPrincipal loadUserInfo(String userName)
|
||||||
{
|
{
|
||||||
UserIdentity id = _propertyUserStore.getUserIdentity(userName);
|
UserIdentity id = _userStore.getUserIdentity(userName);
|
||||||
if (id != null)
|
if (id != null)
|
||||||
{
|
{
|
||||||
return (UserPrincipal)id.getUserPrincipal();
|
return (UserPrincipal)id.getUserPrincipal();
|
||||||
@ -188,15 +195,17 @@ public class HashLoginService extends AbstractLoginService
|
|||||||
{
|
{
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
|
||||||
if (_propertyUserStore == null)
|
// can be null so we switch to previous behaviour using PropertyUserStore
|
||||||
|
if (_userStore == null)
|
||||||
{
|
{
|
||||||
if(LOG.isDebugEnabled())
|
if(LOG.isDebugEnabled())
|
||||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _configFile + " hotReload: " + hotReload);
|
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _configFile + " hotReload: " + hotReload);
|
||||||
|
|
||||||
_propertyUserStore = new PropertyUserStore();
|
PropertyUserStore propertyUserStore = new PropertyUserStore();
|
||||||
_propertyUserStore.setHotReload(hotReload);
|
propertyUserStore.setHotReload(hotReload);
|
||||||
_propertyUserStore.setConfigPath(_configFile);
|
propertyUserStore.setConfigPath(_configFile);
|
||||||
_propertyUserStore.start();
|
propertyUserStore.start();
|
||||||
|
this._userStore = propertyUserStore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +217,8 @@ public class HashLoginService extends AbstractLoginService
|
|||||||
protected void doStop() throws Exception
|
protected void doStop() throws Exception
|
||||||
{
|
{
|
||||||
super.doStop();
|
super.doStop();
|
||||||
if (_propertyUserStore != null)
|
if (_userStore != null)
|
||||||
_propertyUserStore.stop();
|
_userStore.stop();
|
||||||
_propertyUserStore = null;
|
_userStore = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user