use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class QuickStartWebApp method doStart.
@Override
protected void doStart() throws Exception {
// unpack and Adjust paths.
Resource war = null;
Resource dir = null;
Resource base = getBaseResource();
if (base == null)
base = Resource.newResource(getWar());
if (base.isDirectory())
dir = base;
else if (base.toString().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
war = base;
String w = war.toString();
dir = Resource.newResource(w.substring(0, w.length() - 4));
if (!dir.exists()) {
LOG.info("Quickstart Extract " + war + " to " + dir);
dir.getFile().mkdirs();
JarResource.newJarResource(war).copyTo(dir.getFile());
}
setWar(null);
setBaseResource(dir);
} else
throw new IllegalArgumentException();
Resource qswebxml = dir.addPath("/WEB-INF/quickstart-web.xml");
if (isPreconfigure()) {
_preconfigProcessor = new PreconfigureDescriptorProcessor();
getMetaData().addDescriptorProcessor(_preconfigProcessor);
_startWebapp = false;
} else if (qswebxml.exists()) {
setConfigurationClasses(__configurationClasses);
_startWebapp = true;
} else if (_autoPreconfigure) {
LOG.info("Quickstart preconfigure: {}(war={},dir={})", this, war, dir);
_preconfigProcessor = new PreconfigureDescriptorProcessor();
getMetaData().addDescriptorProcessor(_preconfigProcessor);
setPreconfigure(true);
_startWebapp = true;
} else
_startWebapp = true;
super.doStart();
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class JDBCLoginService method doStart.
/* ------------------------------------------------------------ */
@Override
protected void doStart() throws Exception {
Properties properties = new Properties();
Resource resource = Resource.newResource(_config);
try (InputStream in = resource.getInputStream()) {
properties.load(in);
}
_jdbcDriver = properties.getProperty("jdbcdriver");
_url = properties.getProperty("url");
_userName = properties.getProperty("username");
_password = properties.getProperty("password");
String _userTable = properties.getProperty("usertable");
_userTableKey = properties.getProperty("usertablekey");
String _userTableUserField = properties.getProperty("usertableuserfield");
_userTablePasswordField = properties.getProperty("usertablepasswordfield");
String _roleTable = properties.getProperty("roletable");
String _roleTableKey = properties.getProperty("roletablekey");
_roleTableRoleField = properties.getProperty("roletablerolefield");
String _userRoleTable = properties.getProperty("userroletable");
String _userRoleTableUserKey = properties.getProperty("userroletableuserkey");
String _userRoleTableRoleKey = properties.getProperty("userroletablerolekey");
if (_jdbcDriver == null || _jdbcDriver.equals("") || _url == null || _url.equals("") || _userName == null || _userName.equals("") || _password == null) {
LOG.warn("UserRealm " + getName() + " has not been properly configured");
}
_userSql = "select " + _userTableKey + "," + _userTablePasswordField + " from " + _userTable + " where " + _userTableUserField + " = ?";
_roleSql = "select r." + _roleTableRoleField + " from " + _roleTable + " r, " + _userRoleTable + " u where u." + _userRoleTableUserKey + " = ?" + " and r." + _roleTableKey + " = u." + _userRoleTableRoleKey;
Loader.loadClass(_jdbcDriver).newInstance();
super.doStart();
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class SpnegoLoginService method doStart.
@Override
protected void doStart() throws Exception {
Properties properties = new Properties();
Resource resource = Resource.newResource(_config);
properties.load(resource.getInputStream());
_targetName = properties.getProperty("targetName");
LOG.debug("Target Name {}", _targetName);
super.doStart();
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testSymlinkKnown.
@Test
public void testSymlinkKnown() throws Exception {
Assume.assumeTrue(OS.IS_UNIX);
try {
allowSymlinks.set(true);
final String path = "/other/other.txt";
Resource resource = context.getResource(path);
assertNotNull(resource);
assertEquals("other.txt", resource.getFile().getName());
assertEquals(docroot, resource.getFile().getParentFile().getParentFile());
assertTrue(resource.exists());
URL url = context.getServletContext().getResource(path);
assertEquals(docroot, new File(url.toURI()).getParentFile().getParentFile());
} finally {
allowSymlinks.set(false);
}
}
use of org.eclipse.jetty.util.resource.Resource in project jetty.project by eclipse.
the class ContextHandlerGetResourceTest method testAliasedFileAllowed.
@Test
public void testAliasedFileAllowed() throws Exception {
Assume.assumeTrue("OS Supports 8.3 Aliased / Alternate References", OS_ALIAS_SUPPORTED);
try {
allowAliases.set(true);
final String path = "/subdir/TEXTFI~1.TXT";
Resource resource = context.getResource(path);
assertNotNull(resource);
assertEquals(context.getResource("/subdir/TextFile.Long.txt").getURI(), resource.getAlias());
URL url = context.getServletContext().getResource(path);
assertNotNull(url);
assertEquals(docroot, new File(url.toURI()).getParentFile().getParentFile());
} finally {
allowAliases.set(false);
}
}
Aggregations