/** * @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; } }
LOG.debug("Loading {} from {}", this, _configPath); Resource config = getConfigResource(); known.add(username); Credential credential = Credential.getCredential(credentials); addUser(username, credential, roleArray); notifyUpdate(username, credential, roleArray); List<String> currentlyKnownUsers = new ArrayList<>(getKnownUserIdentities().keySet()); removeUser(user); notifyRemove(user);
/** * Depending on the value of the refresh interval, this method will either start * up a scanner thread that will monitor the properties file for changes after * it has initially loaded it. Otherwise the users will be loaded and there will * be no active monitoring thread so changes will not be detected. */ @Override protected void doStart() throws Exception { super.doStart(); loadUsers(); if (isHotReload() && (_configPath != null)) { this._pathWatcher = new PathWatcher(); this._pathWatcher.watch(_configPath); this._pathWatcher.addListener(this); this._pathWatcher.setNotifyExistingOnStart(false); this._pathWatcher.start(); } }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ protected void doStart() throws Exception { super.doStart(); if (_propertyUserStore == null) { if(LOG.isDebugEnabled()) LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " refreshInterval: " + _refreshInterval); _propertyUserStore = new PropertyUserStore(); _propertyUserStore.setRefreshInterval(_refreshInterval); _propertyUserStore.setConfig(_config); _propertyUserStore.registerUserListener(this); _propertyUserStore.start(); } }
LOG.debug("Load " + this + " from " + _config); Properties properties = new Properties(); if (getConfigResource().exists()) properties.load(getConfigResource().getInputStream()); Set<String> known = new HashSet<String>(); notifyUpdate(username,credential,roleArray); notifyRemove(user);
if (getRefreshInterval() > 0) _scanner.setScanInterval(getRefreshInterval()); List<File> dirList = new ArrayList<File>(1); dirList.add(getConfigResource().getFile().getParentFile()); _scanner.setScanDirs(dirList); _scanner.setFilenameFilter(new FilenameFilter() loadUsers();
/** * 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; }
/** Very simple! */ private static UserStore makeUserStore(String user, String password, String role) { Credential cred = new Password(password); PropertyUserStore propertyUserStore = new PropertyUserStore(); String[] roles = role == null ? null : new String[]{role}; propertyUserStore.addUser(user, cred, roles); try { propertyUserStore.start(); } catch (Exception ex) { throw new FusekiException("UserStore", ex); } return propertyUserStore; }
public boolean accept(File dir, String name) { File f = new File(dir,name); try { if (f.compareTo(getConfigResource().getFile()) == 0) { return true; } } catch (IOException e) { return false; } return false; }
private static UserStore userStore() { PropertyUserStore propertyUserStore = new PropertyUserStore(); String[] roles = new String[]{"**"}; addUserPassword(propertyUserStore, "userNone", "pwNone", roles); addUserPassword(propertyUserStore, "userDft", "pwDft", roles); addUserPassword(propertyUserStore, "user0", "pw0", roles); addUserPassword(propertyUserStore, "user1", "pw1", roles); addUserPassword(propertyUserStore, "user2", "pw2", roles); addUserPassword(propertyUserStore, "user3", "pw3", roles); return propertyUserStore; }
@Override public void onPathWatchEvent(PathWatchEvent event) { try { if (LOG.isDebugEnabled()) LOG.debug("Path watch event: {}", event.getType()); loadUsers(); } catch (IOException e) { LOG.warn(e); } }
/** * Set the Config Path from a String reference to a file * * @param configFile the config file can a be a file path or a reference to a file within a jar file {@code jar:file:} */ @Deprecated public void setConfigPath(String configFile) { setConfig(configFile); }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ protected void doStart() throws Exception { super.doStart(); if (_propertyUserStore == null) { if(LOG.isDebugEnabled()) LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " refreshInterval: " + _refreshInterval); _propertyUserStore = new PropertyUserStore(); _propertyUserStore.setRefreshInterval(_refreshInterval); _propertyUserStore.setConfig(_config); _propertyUserStore.registerUserListener(this); _propertyUserStore.start(); } }
LOG.debug("Load " + this + " from " + _config); Properties properties = new Properties(); if (getConfigResource().exists()) properties.load(getConfigResource().getInputStream()); Set<String> known = new HashSet<String>(); notifyUpdate(username,credential,roleArray); notifyRemove(user);
if (getRefreshInterval() > 0) _scanner.setScanInterval(getRefreshInterval()); List<File> dirList = new ArrayList<File>(1); dirList.add(getConfigResource().getFile().getParentFile()); _scanner.setScanDirs(dirList); _scanner.setFilenameFilter(new FilenameFilter() loadUsers();
/** * 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; }
public boolean accept(File dir, String name) { File f = new File(dir,name); try { if (f.compareTo(getConfigResource().getFile()) == 0) { return true; } } catch (IOException e) { return false; } return false; }
private static UserStore userStore() { PropertyUserStore propertyUserStore = new PropertyUserStore(); String[] roles = new String[]{"**"}; addUserPassword(propertyUserStore, "userNone", "pwNone", roles); addUserPassword(propertyUserStore, "userDft", "pwDft", roles); addUserPassword(propertyUserStore, "user0", "pw0", roles); addUserPassword(propertyUserStore, "user1", "pw1", roles); addUserPassword(propertyUserStore, "user2", "pw2", roles); addUserPassword(propertyUserStore, "user3", "pw3", roles); return propertyUserStore; }
@Override public void onPathWatchEvent(PathWatchEvent event) { try { loadUsers(); } catch (IOException e) { LOG.warn(e); } }
/** * Set the Config Path from a String reference to a file * @param configFile the config file can a be a file path or a reference to a file within a jar file <code>jar:file:</code> */ @Deprecated public void setConfigPath(String configFile) { setConfig(configFile); }