Package org.beangle.security.blueprint

Examples of org.beangle.security.blueprint.User


  /**
   * 主页面
   */
  public String index() {
    User user = getUser();
    put("manager", user);
    if (isAdmin(user)) {
      put("allGroups", entityDao.getAll(Group.class));
    }
    return forward();
View Full Code Here


    Long groupId = getLong("group.id");
    if (null == groupId) {
      groupId = getLong("groupIds");
    }
    Group ao = entityDao.get(Group.class, groupId);
    User user = getUser();
    put("manager", user);
    if (isAdmin(user)) {
      put("allGroups", entityDao.getAll(Group.class));
    }
    List<UserCategory> categories = CollectUtils.newArrayList();
View Full Code Here

        getLong("menuProfileId"));
    Set<Resource> newResources = CollectUtils.newHashSet(entityDao.get(Resource.class,
        SeqStrUtils.transformToLong(get("resourceId"))));

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

    if (StringUtils.isEmpty(name) || StringUtils.isEmpty(email)) {
      addActionError("error.parameters.needed");
      return (ERROR);
    }
    List<User> userList = entityDao.get(User.class, "name", name);
    User user = null;
    if (userList.isEmpty()) {
      return goErrorWithMessage("error.user.notExist");
    } else {
      user = userList.get(0);
    }
    if (!StringUtils.equals(email, user.getMail())) {
      return goErrorWithMessage("error.email.notEqualToOrign");
    } else {
      String longinName = user.getName();
      String password = RandomStringUtils.randomNumeric(6);
      user.setRemark(password);
      user.setPassword(EncryptUtil.encode(password));
      String title = getText("user.password.sendmail.title");

      List<Object> values = CollectUtils.newArrayList();
      values.add(longinName);
      values.add(password);
      String body = getText("user.password.sendmail.body", values);
      try {
        SimpleMailMessage msg = new SimpleMailMessage(message);
        msg.setTo(user.getMail());
        msg.setSubject(title);
        msg.setText(body.toString());
        mailSender.send(msg);
      } catch (Exception e) {
        e.printStackTrace();
        logger.info("reset password error for user:" + user.getName() + " with email :"
            + user.getMail());
        return goErrorWithMessage("error.email.sendError");
      }
    }
    entityDao.saveOrUpdate(user);
    return forward("sendResult");
View Full Code Here

      }
      return redirect("admin", "info.remove.success");
    }
    String newAdmin = get("newAdmin");
    if (StringUtils.isNotBlank(newAdmin)) {
      User user = authorityService.getUserService().get(newAdmin);
      if (null == user) {
        return redirect("admin", "info.save.failure");
      } else {
        if (authorityService.getUserService().isAdmin(user)) { return redirect("admin",
            "info.save.failure"); }
View Full Code Here

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

    put("categories", entityDao.getAll(UserCategory.class));
  }

  public String dashboard() {
    Long userId = getLong("user.id");
    User me = getUser();
    if (null != userId) {
      User managed = (User) entityDao.get(User.class, userId);
      if (me.equals(managed) || userService.isManagedBy(me, managed)) {
        userDashboardHelper.buildDashboard(managed);
        return forward();
      } else {
        return forward(ERROR);
View Full Code Here

    }
    return forward();
  }

  protected OqlBuilder<User> getQueryBuilder() {
    User manager = getUser();
    OqlBuilder<User> userQuery = OqlBuilder.from(entityName, "user");
    // 查询用户组
    StringBuilder sb = new StringBuilder("exists(from user.groups ug where ");
    List<Object> params = CollectUtils.newArrayList();
    boolean queryGroup = false;
View Full Code Here

  /**
   * 保存用户信息
   */
  protected String saveAndForward(Entity<?> entity) {
    User user = (User) entity;
    String errorMsg = "";
    // // 收集用户身份
    String[] categories = StringUtils.split(get("categoryIds"), ",");
    for (int i = 0; i < categories.length; i++) {
      errorMsg = checkCategory(user, Long.valueOf(categories[i]));
      if (StringUtils.isNotEmpty(errorMsg)) { return forward(new Action("edit"), errorMsg); }
    }
    // 检验用户合法性
    errorMsg = checkUser(user);
    if (StringUtils.isNotEmpty(errorMsg)) { return forward(new Action("edit"), errorMsg); }
    try {
      processPassword(user);
      if (!user.isPersisted()) {
        User creator = userService.get(getUserId());
        userService.createUser(creator, user);
      } else {
        userService.saveOrUpdate(user);
      }
      updateUserGroup(user);
View Full Code Here

    for (GroupMember gm : userMembers) {
      memberMap.put(gm.getGroup(), gm);
    }
    Set<GroupMember> newMembers = CollectUtils.newHashSet();
    Set<GroupMember> removedMembers = CollectUtils.newHashSet();
    User manager = getUser();
    Collection<GroupMember> members = userService.getGroupMembers(manager,
        GroupMember.Ship.GRANTER);
    for (GroupMember member : members) {
      GroupMember myMember = memberMap.get(member.getGroup());
      boolean isMember = getBool("member" + member.getGroup().getId());
View Full Code Here

TOP

Related Classes of org.beangle.security.blueprint.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.