@Override protected UserPrincipal loadUserInfo(String userName) { UserIdentity id = _userStore.getUserIdentity(userName); if (id != null) { return (UserPrincipal)id.getUserPrincipal(); } return null; }
/** * 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(); } }
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore makeUserStore(String user, String password, String role) { Objects.requireNonNull(user); Objects.requireNonNull(password); Objects.requireNonNull(role); UserStore userStore = new UserStore(); addUser(userStore, user, password, role); try { userStore.start(); } catch (Exception ex) { throw new RuntimeException("UserStore", ex); } return userStore; } public static UserStore addUser(UserStore userStore, String user, String password) {
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore addUser(UserStore userStore, String user, String password, String role) { String[] roles = role == null ? null : new String[]{role}; Credential cred = new Password(password); userStore.addUser(user, cred, roles); return userStore; }
loginService.setUserStore(new UserStore()); this.server.addBean(loginService);
@Override protected void doStop() throws Exception { super.doStop(); if (this._pathWatcher != null) this._pathWatcher.stop(); this._pathWatcher = null; }
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore makeUserStore(String user, String password, String role) { Objects.requireNonNull(user); Objects.requireNonNull(password); Objects.requireNonNull(role); UserStore userStore = new UserStore(); addUser(userStore, user, password, role); try { userStore.start(); } catch (Exception ex) { throw new RuntimeException("UserStore", ex); } return userStore; } public static UserStore addUser(UserStore userStore, String user, String password) {
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore addUser(UserStore userStore, String user, String password, String role) { String[] roles = role == null ? null : new String[]{role}; Credential cred = new Password(password); userStore.addUser(user, cred, roles); return userStore; }
/** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop() */ @Override protected void doStop() throws Exception { super.doStop(); if (this._pathWatcher != null) this._pathWatcher.stop(); this._pathWatcher = null; }
/** * Configures a security realm for a test. */ protected LoginService configureUserRealm() { HashLoginService realm = new HashLoginService(); realm.setName("default"); // this is the magic realm name to make it effective on everywhere UserStore userStore = new UserStore(); realm.setUserStore( userStore ); userStore.addUser("alice", new Password("alice"), new String[]{"user","female"}); userStore.addUser("bob", new Password("bob"), new String[]{"user","male"}); userStore.addUser("charlie", new Password("charlie"), new String[]{"user","male"}); return realm; }
private void putUser(String name, String sisma) { userStore.addUser(name, Credential.getCredential(sisma), new String[]{"user"}); }
@Override protected String[] loadRoleInfo(UserPrincipal user) { UserIdentity id = _userStore.getUserIdentity(user.getName()); if (id == null) return null; Set<RolePrincipal> roles = id.getSubject().getPrincipals(RolePrincipal.class); if (roles == null) return null; List<String> list = roles.stream() .map( rolePrincipal -> rolePrincipal.getName() ) .collect( Collectors.toList() ); return list.toArray(new String[roles.size()]); }
/** * 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. * * * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @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(); } }
/** * Configures a security realm for a test. */ protected LoginService configureUserRealm() { HashLoginService realm = new HashLoginService(); realm.setName("default"); // this is the magic realm name to make it effective on everywhere UserStore userStore = new UserStore(); realm.setUserStore( userStore ); userStore.addUser("alice", new Password("alice"), new String[]{"user","female"}); userStore.addUser("bob", new Password("bob"), new String[]{"user","male"}); userStore.addUser("charlie", new Password("charlie"), new String[]{"user","male"}); return realm; }
public boolean isUserExists(String username) { return userStore.getUserIdentity(username) != null; }
@Override protected UserPrincipal loadUserInfo(String userName) { UserIdentity id = _userStore.getUserIdentity(userName); if (id != null) { return (UserPrincipal)id.getUserPrincipal(); } return null; }