Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Jan Bartel 2017-05-01 17:53:38 +02:00
commit 84bc74754d
5 changed files with 44 additions and 39 deletions

View File

@ -50,8 +50,7 @@ public class HashLoginService extends AbstractLoginService
{
private static final Logger LOG = Log.getLogger(HashLoginService.class);
private File _configFile;
private Resource _configResource;
private String _config;
private boolean hotReload = false; // default is not to reload
private UserStore _userStore;
private boolean _userStoreAutoCreate = false;
@ -78,28 +77,15 @@ public class HashLoginService extends AbstractLoginService
/* ------------------------------------------------------------ */
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;
}
/* ------------------------------------------------------------ */
@ -109,12 +95,11 @@ public class HashLoginService extends AbstractLoginService
* 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;
}
/**
@ -200,11 +185,10 @@ public class HashLoginService extends AbstractLoginService
if (_userStore == 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 propertyUserStore = new PropertyUserStore();
propertyUserStore.setHotReload(hotReload);
propertyUserStore.setConfigPath(_configFile);
propertyUserStore.setConfigPath(_config);
propertyUserStore.start();
_userStore = propertyUserStore;
_userStoreAutoCreate = true;

View File

@ -29,6 +29,7 @@ import org.eclipse.jetty.util.security.Credential;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
@ -73,18 +74,30 @@ public class PropertyUserStore extends UserStore implements PathWatcher.Listener
@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);
}
}
/**

View File

@ -41,6 +41,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";
@ -106,12 +113,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());
}
}

View File

@ -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 -->
<!--
<Set name="hotReload">false</Set>

View File

@ -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>