Package org.onebusaway.users.model

Examples of org.onebusaway.users.model.UserRole


  @Test
  public void test() {

    assertEquals(0, _dao.getNumberOfUserRoles());

    UserRole adminRole = new UserRole("admin");
    UserRole userRole = new UserRole("user");

    _dao.saveOrUpdateUserRole(adminRole);
    _dao.saveOrUpdateUserRole(userRole);

    assertEquals(2, _dao.getNumberOfUserRoles());
View Full Code Here


  }

  @Test
  public void deleteUser() {

    UserRole userRole = new UserRole("user");

    _dao.saveOrUpdateUserRole(userRole);

    User user = new User();
    user.setCreationTime(new Date());
View Full Code Here

    return _userDao.getAllUserIdsInRange(offset, limit);
  }

  @Override
  public int getNumberOfAdmins() {
    UserRole admin = _authoritiesService.getAdministratorRole();
    return _userDao.getNumberOfUsersWithRole(admin);
  }
View Full Code Here

  public UserBean getUserAsBean(User user) {

    UserBean bean = new UserBean();
    bean.setUserId(Integer.toString(user.getId()));

    UserRole anonymous = _authoritiesService.getAnonymousRole();
    boolean isAnonymous = user.getRoles().contains(anonymous);
    bean.setAnonymous(isAnonymous);

    UserRole admin = _authoritiesService.getAdministratorRole();
    boolean isAdmin = user.getRoles().contains(admin);
    bean.setAdmin(isAdmin);

    List<UserIndexBean> indices = new ArrayList<UserIndexBean>();
    bean.setIndices(indices);
View Full Code Here

  }

  @Override
  public void enableAdminRoleForUser(User user, boolean onlyIfNoOtherAdmins) {

    UserRole adminRole = _authoritiesService.getUserRoleForName(StandardAuthoritiesService.ADMINISTRATOR);

    if (onlyIfNoOtherAdmins) {
      int count = _userDao.getNumberOfUsersWithRole(adminRole);
      if (count > 0)
        return;
View Full Code Here

      _userDao.saveOrUpdateUser(user);
  }

  public void disableAdminRoleForUser(User user, boolean onlyIfOtherAdmins) {

    UserRole adminRole = _authoritiesService.getUserRoleForName(StandardAuthoritiesService.ADMINISTRATOR);

    if (onlyIfOtherAdmins) {
      int count = _userDao.getNumberOfUsersWithRole(adminRole);
      if (count < 2)
        return;
View Full Code Here

  private void mergeRoles(User sourceUser, User targetUser) {
    Set<UserRole> roles = new HashSet<UserRole>();
    roles.addAll(sourceUser.getRoles());
    roles.addAll(targetUser.getRoles());

    UserRole anon = _authoritiesService.getAnonymousRole();
    UserRole user = _authoritiesService.getUserRole();
    if (roles.contains(user))
      roles.remove(anon);

    targetUser.setRoles(roles);
  }
View Full Code Here

  private GrantedAuthority createStandardAuthority(final String name) {

    assert !_standardAuthoritiesMap.containsKey(name);
    assert !_userRoles.containsKey(name);

    UserRole role = _userDao.getUserRoleForName(name);
    if (role == null) {
      role = new UserRole(name);
      _userDao.saveOrUpdateUserRole(role);
    }
    _userRoles.put(name, role);

    final GrantedAuthority auth = new GrantedAuthorityImpl(name);
View Full Code Here

TOP

Related Classes of org.onebusaway.users.model.UserRole

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.