parent
a4cfd8a7a5
commit
5f65f2916f
|
@ -53,8 +53,7 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
private static final Logger LOG = Log.getLogger(HashLoginService.class);
|
||||
|
||||
private PropertyUserStore _propertyUserStore;
|
||||
private File _configFile;
|
||||
private Resource _configResource;
|
||||
private String _config;
|
||||
private boolean hotReload = false; // default is not to reload
|
||||
|
||||
|
||||
|
@ -100,28 +99,15 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
/* ------------------------------------------------------------ */
|
||||
public String getConfig()
|
||||
{
|
||||
if(_configFile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _configFile.getAbsolutePath();
|
||||
return _config;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setConfig(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void getConfig(String config)
|
||||
{
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Resource getConfigResource()
|
||||
{
|
||||
return _configResource;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -131,12 +117,11 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
* The property file maps usernames to password specs followed by an optional comma separated list of role names.
|
||||
* </p>
|
||||
*
|
||||
* @param configFile
|
||||
* Filename of user properties file.
|
||||
* @param config uri or url or path to realm properties file
|
||||
*/
|
||||
public void setConfig(String configFile)
|
||||
public void setConfig(String config)
|
||||
{
|
||||
_configFile = new File(configFile);
|
||||
_config=config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,11 +231,10 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
if (_propertyUserStore == null)
|
||||
{
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _configFile + " hotReload: " + hotReload);
|
||||
|
||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " hotReload: " + hotReload);
|
||||
_propertyUserStore = new PropertyUserStore();
|
||||
_propertyUserStore.setHotReload(hotReload);
|
||||
_propertyUserStore.setConfigPath(_configFile);
|
||||
_propertyUserStore.setConfigPath(_config);
|
||||
_propertyUserStore.registerUserListener(this);
|
||||
_propertyUserStore.start();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.security;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
|
@ -84,18 +85,30 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
|
|||
@Deprecated
|
||||
public String getConfig()
|
||||
{
|
||||
return _configPath.toString();
|
||||
if (_configPath != null)
|
||||
return _configPath.toString();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Config Path from a String reference to a file
|
||||
* @param configFile the config file
|
||||
* @deprecated use {@link #setConfigPath(String)} instead
|
||||
* @param config the config file
|
||||
*/
|
||||
@Deprecated
|
||||
public void setConfig(String configFile)
|
||||
public void setConfig(String config)
|
||||
{
|
||||
setConfigPath(configFile);
|
||||
try
|
||||
{
|
||||
Resource configResource = Resource.newResource(config);
|
||||
if (configResource.getFile() != null)
|
||||
setConfigPath(configResource.getFile());
|
||||
else
|
||||
throw new IllegalArgumentException(config+" is not a file");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,13 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(JettyWebXmlConfiguration.class);
|
||||
|
||||
/** The value of this property points to the WEB-INF directory of
|
||||
* the web-app currently installed.
|
||||
* it is passed as a property to the jetty-web.xml file */
|
||||
@Deprecated
|
||||
public static final String PROPERTY_THIS_WEB_INF_URL = "this.web-inf.url";
|
||||
public static final String PROPERTY_WEB_INF_URI = "web-inf.uri";
|
||||
public static final String PROPERTY_WEB_INF = "web-inf";
|
||||
public static final String XML_CONFIGURATION = "org.eclipse.jetty.webapp.JettyWebXmlConfiguration";
|
||||
public static final String JETTY_WEB_XML = "jetty-web.xml";
|
||||
|
||||
|
@ -117,12 +124,8 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
|||
private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf) throws IOException
|
||||
{
|
||||
Map<String,String> props = jetty_config.getProperties();
|
||||
props.put("this.web-inf.url", web_inf.getURI().toURL().toExternalForm());
|
||||
String webInfPath = web_inf.getFile().getAbsolutePath();
|
||||
if (!webInfPath.endsWith(File.separator))
|
||||
{
|
||||
webInfPath += File.separator;
|
||||
}
|
||||
props.put("this.web-inf.path", webInfPath);
|
||||
props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURI().toString());
|
||||
props.put(PROPERTY_WEB_INF_URI, web_inf.getURI().toString());
|
||||
props.put(PROPERTY_WEB_INF, web_inf.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@ detected.
|
|||
<Set name="loginService">
|
||||
<New class="org.eclipse.jetty.security.HashLoginService">
|
||||
<Set name="name">Test Realm</Set>
|
||||
<Set name="config"><Property name="this.web-inf.path"/>realm.properties</Set>
|
||||
<Set name="config">
|
||||
<Property name="web-inf.uri">/realm.properties</Property>
|
||||
</Set>
|
||||
<!-- To enable reload of realm when properties change, uncomment the following lines -->
|
||||
<!-- changing refreshInterval (in seconds) as desired -->
|
||||
<!--
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
</excludes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<!-- Removed until PropertyUserStore supports packed realm.properties -->
|
||||
<!--
|
||||
<files>
|
||||
<file>
|
||||
<source>src/main/assembly/embedded-jetty-web-for-webbundle.xml</source>
|
||||
|
@ -32,4 +34,5 @@
|
|||
<destName>realm.properties</destName>
|
||||
</file>
|
||||
</files>
|
||||
-->
|
||||
</assembly>
|
||||
|
|
Loading…
Reference in New Issue