Issue #1390 - Addressing new File(URL) use in Windows
+ Fixing HashLoginService to track its Config via File reference only (dropping support for URL reference) + Adding new `this.web-inf.path` property that jetty-web.xml can use
This commit is contained in:
parent
5933f70ae6
commit
e25007cb79
|
@ -373,7 +373,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<Arg>
|
||||
<New class="org.eclipse.jetty.security.HashLoginService">
|
||||
<Set name="name">Test Realm</Set>
|
||||
<Set name="config"><Property name="jetty.home" default="src/test/config"/>realm.properties</Set>
|
||||
<Set name="config"><Property name="jetty.home" default="src/test/config"/>/realm.properties</Set>
|
||||
<Set name="refreshInterval">0</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
|
|
|
@ -18,16 +18,22 @@
|
|||
|
||||
package org.eclipse.jetty.osgi.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
|
||||
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -37,12 +43,6 @@ import org.ops4j.pax.exam.Option;
|
|||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
|
||||
import static org.ops4j.pax.exam.CoreOptions.options;
|
||||
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
|
||||
|
||||
/**
|
||||
* Pax-Exam to make sure the jetty-osgi-boot can be started along with the
|
||||
* httpservice web-bundle. Then make sure we can deploy an OSGi service on the
|
||||
|
@ -71,12 +71,13 @@ public class TestJettyOSGiBootWithJsp
|
|||
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
|
||||
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
|
||||
options.addAll(jspDependencies());
|
||||
options.add(CoreOptions.cleanCaches(true));
|
||||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(boolean ssl,String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
File etc = new File(OS.separators("src/test/config/etc"));
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# LOG4J levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL
|
||||
#
|
||||
log4j.rootLogger=WARN,CONSOLE
|
||||
log4j.rootLogger=DEBUG,CONSOLE
|
||||
|
||||
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
|
||||
#log4j.appender.CONSOLE.threshold=INFO
|
||||
|
@ -9,5 +9,8 @@ log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
|
|||
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%5p][%c] %m%n
|
||||
|
||||
# Level tuning
|
||||
log4j.logger.org.eclipse.jetty=DEBUG
|
||||
#log4j.logger.org.ops4j=INFO
|
||||
# log4j.logger.org.eclipse.jetty=DEBUG
|
||||
# log4j.logger.org.eclipse.jetty.security=DEBUG
|
||||
log4j.logger.shaded.org.eclipse.aether=WARN
|
||||
log4j.logger.shaded.org.apache.http=WARN
|
||||
log4j.logger.org.ops4j=WARN
|
||||
|
|
|
@ -18,15 +18,14 @@
|
|||
|
||||
package org.eclipse.jetty.security;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.security.MappedLoginService.KnownUser;
|
||||
import org.eclipse.jetty.security.PropertyUserStore.UserListener;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
@ -54,7 +53,7 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
private static final Logger LOG = Log.getLogger(HashLoginService.class);
|
||||
|
||||
private PropertyUserStore _propertyUserStore;
|
||||
private String _config;
|
||||
private File _configFile;
|
||||
private Resource _configResource;
|
||||
private boolean hotReload = false; // default is not to reload
|
||||
|
||||
|
@ -101,13 +100,22 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
/* ------------------------------------------------------------ */
|
||||
public String getConfig()
|
||||
{
|
||||
return _config;
|
||||
if(_configFile == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _configFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setConfig(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void getConfig(String config)
|
||||
{
|
||||
_config = config;
|
||||
setConfig(config);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -118,14 +126,17 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Load realm users from properties file. The property file maps usernames to password specs followed by an optional comma separated list of role names.
|
||||
* Load realm users from properties file.
|
||||
* <p>
|
||||
* The property file maps usernames to password specs followed by an optional comma separated list of role names.
|
||||
* </p>
|
||||
*
|
||||
* @param config
|
||||
* Filename or url of user properties file.
|
||||
* @param configFile
|
||||
* Filename of user properties file.
|
||||
*/
|
||||
public void setConfig(String config)
|
||||
public void setConfig(String configFile)
|
||||
{
|
||||
_config = config;
|
||||
_configFile = new File(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,11 +246,11 @@ public class HashLoginService extends MappedLoginService implements UserListener
|
|||
if (_propertyUserStore == null)
|
||||
{
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " hotReload: " + hotReload);
|
||||
LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _configFile + " hotReload: " + hotReload);
|
||||
|
||||
_propertyUserStore = new PropertyUserStore();
|
||||
_propertyUserStore.setHotReload(hotReload);
|
||||
_propertyUserStore.setConfigPath(_config);
|
||||
_propertyUserStore.setConfigPath(_configFile);
|
||||
_propertyUserStore.registerUserListener(this);
|
||||
_propertyUserStore.start();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
|
@ -40,12 +42,6 @@ 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 */
|
||||
public static final String PROPERTY_THIS_WEB_INF_URL = "this.web-inf.url";
|
||||
|
||||
|
||||
public static final String XML_CONFIGURATION = "org.eclipse.jetty.webapp.JettyWebXmlConfiguration";
|
||||
public static final String JETTY_WEB_XML = "jetty-web.xml";
|
||||
|
||||
|
@ -118,10 +114,15 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
|||
* @param jetty_config The configuration object.
|
||||
* @param web_inf the WEB-INF location
|
||||
*/
|
||||
private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf)
|
||||
private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf) throws IOException
|
||||
{
|
||||
Map<String,String> props = jetty_config.getProperties();
|
||||
// TODO - should this be an id rather than a property?
|
||||
props.put(PROPERTY_THIS_WEB_INF_URL, String.valueOf(web_inf.getURL()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ 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.url"/>realm.properties</Set>
|
||||
<Set name="config"><Property name="this.web-inf.path"/>realm.properties</Set>
|
||||
<!-- To enable reload of realm when properties change, uncomment the following lines -->
|
||||
<!-- changing refreshInterval (in seconds) as desired -->
|
||||
<!--
|
||||
|
|
Loading…
Reference in New Issue