Package org.beangle.ems.security

Examples of org.beangle.ems.security.User


  public UserDetail loadDetail(Authentication auth) {
    List<User> users = entityDao.get(User.class, "name", auth.getName());
    if (users.isEmpty()) {
      return null;
    } else {
      User user = users.get(0);
      List<Group> groups = userService.getGroups(user, GroupMember.Ship.MEMBER);
      List<GrantedAuthorityBean> authorities = CollectUtils.newArrayList(groups.size());
      for (Group g : groups) {
        authorities.add(new GrantedAuthorityBean(g.getName()));
      }
      return new UserToken(user.getId(), user.getName(), user.getFullname(), user.getPassword(),
          entityDao.initialize(user.getDefaultCategory()).getTitle(), user.isEnabled(),
          user.isAccountExpired(), user.isPasswordExpired(), false, authorities);
    }
  }
View Full Code Here


  public int updateState(final User manager, Long[] ids, final boolean enabled) {
    assert (null == ids || ids.length < 1);
    @SuppressWarnings("unchecked")
    List<User> users = (List<User>) CollectionUtils.select(getUsers(ids), new Predicate() {
      public boolean evaluate(Object object) {
        User one = (User) object;
        return isManagedBy(manager, one) && !manager.equals(one) && (one.isEnabled() != enabled);
      }
    });

    for (int i = 0; i < users.size(); i++) {
      User cur = users.get(i);
      cur.setEnabled(enabled);
    }
    if (!users.isEmpty()) {
      entityDao.saveOrUpdate(users);
      publish(new UserStatusEvent(users, enabled));
    }
View Full Code Here

      session.put("security.restriction", restrictionMap);
    }
    Resource resource = getResource();
    if (resource.getEntities().isEmpty()) { return Collections.emptyList(); }
    List<Restriction> realms = restrictionMap.get(resource.getId());
    User user = entityDao.get(User.class, getUserId());
    if (null == realms) {
      realms = restrictionService.getRestrictions(user, resource);
      restrictionMap.put(resource.getId(), realms);
    }
    // 没有权限就报错
View Full Code Here

  }

  protected Long getUserCategoryId() {
    Long categoryId = getLong("security.categoryId");
    if (null == categoryId) {
      User user = entityDao.get(User.class, getUserId());
      categoryId = user.getDefaultCategory().getId();
    }
    return categoryId;
  }
View Full Code Here

  private List<Restriction> getMyRestrictions(RestrictPattern pattern,
      RestrictionHolder<? extends Restriction> holder) {
    String type = get("restrictionType");
    List<Restriction> restrictions = CollectUtils.newArrayList();
    User me = entityDao.get(User.class, getUserId());
    if (type.equals("user")) {
      restrictions = CollectUtils.newArrayList(((RestrictionHolder<?>) me).getRestrictions());
    } else if (type.equals("group")) {
      for (GroupMember group : me.getGroups()) {
        restrictions.addAll(group.getGroup().getRestrictions());
      }
    } else if (type.equals("authority")) {
      Object aa = holder;
      restrictions = restrictionService.getAuthorityRestrictions(me, ((Authority) aa).getResource());
View Full Code Here

    Long groupId = getLong("group.id");
    if (null == groupId) {
      groupId = getLong("groupIds");
    }
    Group ao = entityDao.get(Group.class, groupId);
    User user = entityDao.get(User.class, getUserId());
    put("manager", user);
    List<Group> mngGroups = CollectUtils.newArrayList();
    if (isAdmin()) {
      mngGroups = entityDao.getAll(Group.class);
    } else {
      for (GroupMember m : user.getGroups()) {
        if (m.isManager()) mngGroups.add(m.getGroup());
      }
    }
    put("mngGroups", mngGroups);
View Full Code Here

    MenuProfile menuProfile = (MenuProfile) entityDao.get(MenuProfile.class, getLong("menuProfileId"));
    Set<Resource> newResources = CollectUtils.newHashSet(entityDao.get(Resource.class,
        StrUtils.splitToLong(get("resourceId"))));

    // 管理员拥有的菜单权限和系统资源
    User manager = entityDao.get(User.class, getUserId());
    Set<Menu> mngMenus = null;
    Set<Resource> mngResources = CollectUtils.newHashSet();
    if (isAdmin()) {
      mngMenus = CollectUtils.newHashSet(menuProfile.getMenus());
    } else {
View Full Code Here

  public int updateState(final User manager, Long[] ids, final boolean enabled) {
    assert (null == ids || ids.length < 1);
    @SuppressWarnings("unchecked")
    List<User> users = (List<User>) CollectionUtils.select(getUsers(ids), new Predicate() {
      public boolean evaluate(Object object) {
        User one = (User) object;
        return isManagedBy(manager, one) && !manager.equals(one) && (one.isEnabled() != enabled);
      }
    });

    for (int i = 0; i < users.size(); i++) {
      User cur = users.get(i);
      cur.setEnabled(enabled);
    }
    if (!users.isEmpty()) {
      entityDao.saveOrUpdate(users);
      publish(new UserStatusEvent(users, enabled));
    }
View Full Code Here

  public int updateState(final User manager, Long[] ids, final boolean enabled) {
    assert (null == ids || ids.length < 1);
    @SuppressWarnings("unchecked")
    List<User> users = (List<User>) CollectionUtils.select(getUsers(ids), new Predicate() {
      public boolean evaluate(Object object) {
        User one = (User) object;
        return isManagedBy(manager, one) && !manager.equals(one) && (one.isEnabled() != enabled);
      }
    });

    for (int i = 0; i < users.size(); i++) {
      User cur = users.get(i);
      cur.setEnabled(enabled);
    }
    if (!users.isEmpty()) {
      entityDao.saveOrUpdate(users);
      publish(new AccountStatusEvent(users, enabled));
    }
View Full Code Here

  public UserDetail loadDetail(Authentication auth) {
    List<User> users = entityDao.get(User.class, "name", auth.getName());
    if (users.isEmpty()) {
      return null;
    } else {
      User user = users.get(0);
      List<Group> groups = user.getGroups();
      List<GrantedAuthorityBean> authorities = CollectUtils.newArrayList(groups.size());
      Group defaultGroup = null;
      for (Group g : groups) {
        authorities.add(new GrantedAuthorityBean(g.getName()));
        if (groupProfileService.hasProfile(g)) {
          defaultGroup = g;
        }
      }
      String categoryName = (null == defaultGroup) ? "default" : defaultGroup.getName();
      return new UserToken(user.getId(), user.getName(), user.getFullname(), user.getPassword(),
          categoryName, user.isEnabled(), user.isAccountExpired(), user.isPasswordExpired(), false,
          authorities);
    }
  }
View Full Code Here

TOP

Related Classes of org.beangle.ems.security.User

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.