private Path extractPackedFile(JarFileResource configResource) throws IOException { String uri = configResource.getURI().toASCIIString(); int colon = uri.lastIndexOf(":"); int bang_slash = uri.indexOf("!/"); if (colon < 0 || bang_slash < 0 || colon > bang_slash) throw new IllegalArgumentException("Not resolved JarFile resource: " + uri); String entry_path = uri.substring(colon + 2).replace("!/", "__").replace('/', '_').replace('.', '_'); Path tmpDirectory = Files.createTempDirectory("users_store"); tmpDirectory.toFile().deleteOnExit(); Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path); Files.deleteIfExists(extractedPath); extractedPath.toFile().deleteOnExit(); IO.copy(configResource.getInputStream(), new FileOutputStream(extractedPath.toFile())); if (isHotReload()) { LOG.warn("Cannot hot reload from packed configuration: {}", configResource); setHotReload(false); } return extractedPath; }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { super.doStart(); // can be null so we switch to previous behaviour using PropertyUserStore if (_userStore == null) { if(LOG.isDebugEnabled()) LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " hotReload: " + hotReload); PropertyUserStore propertyUserStore = new PropertyUserStore(); propertyUserStore.setHotReload(hotReload); propertyUserStore.setConfigPath(_config); propertyUserStore.start(); _userStore = propertyUserStore; _userStoreAutoCreate = true; } }
private Path extractPackedFile( JarFileResource configResource ) throws IOException { String uri = configResource.getURI().toASCIIString(); int colon = uri.lastIndexOf(":"); int bang_slash = uri.indexOf("!/"); if (colon<0 || bang_slash<0 || colon>bang_slash) throw new IllegalArgumentException("Not resolved JarFile resource: "+uri); String entry_path = uri.substring(colon+2).replace("!/","__").replace('/','_').replace('.','_'); Path tmpDirectory = Files.createTempDirectory( "users_store" ); tmpDirectory.toFile().deleteOnExit(); Path extractedPath = Paths.get(tmpDirectory.toString(), entry_path); Files.deleteIfExists( extractedPath ); extractedPath.toFile().deleteOnExit(); IO.copy(configResource.getInputStream(),new FileOutputStream(extractedPath.toFile())); if (isHotReload()) { LOG.warn("Cannot hot reload from packed configuration: {}",configResource); setHotReload(false); } return extractedPath; }
/** * Make a {@link UserStore} from a password file. * {@link PropertyUserStore} for details. */ public static UserStore makeUserStore(String passwordFile) { PropertyUserStore propertyUserStore = new PropertyUserStore(); propertyUserStore.setConfig(passwordFile); propertyUserStore.setHotReload(true); try { propertyUserStore.start(); } catch (Exception ex) { throw new RuntimeException("UserStore", ex); } return propertyUserStore; }
/** * Make a {@link UserStore} from a password file. * {@link PropertyUserStore} for details. */ public static UserStore makeUserStore(String passwordFile) { PropertyUserStore propertyUserStore = new PropertyUserStore(); propertyUserStore.setConfig(passwordFile); propertyUserStore.setHotReload(true); try { propertyUserStore.start(); } catch (Exception ex) { throw new RuntimeException("UserStore", ex); } return propertyUserStore; }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { super.doStart(); // can be null so we switch to previous behaviour using PropertyUserStore if (_userStore == null) { if(LOG.isDebugEnabled()) LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " hotReload: " + hotReload); PropertyUserStore propertyUserStore = new PropertyUserStore(); propertyUserStore.setHotReload(hotReload); propertyUserStore.setConfigPath(_config); propertyUserStore.start(); _userStore = propertyUserStore; _userStoreAutoCreate = true; } }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { super.doStart(); if (_propertyUserStore == null) { if(LOG.isDebugEnabled()) LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " hotReload: " + hotReload); _propertyUserStore = new PropertyUserStore(); _propertyUserStore.setHotReload(hotReload); _propertyUserStore.setConfigPath(_config); _propertyUserStore.registerUserListener(this); _propertyUserStore.start(); } }