Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Beangle, Agile Development Scaffold and Toolkit
*
* Copyright (c) 2005-2016, Beangle Software.
*
* Beangle is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Beangle is distributed in the hope that it will be useful.
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Beangle. If not, see .
*/
package org.beangle.ems.security.web.action;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.beangle.commons.bean.comparators.PropertyComparator;
import org.beangle.commons.collection.CollectUtils;
import org.beangle.commons.lang.Strings;
import org.beangle.ems.web.action.SecurityActionSupport;
import org.beangle.security.blueprint.Resource;
import org.beangle.security.blueprint.Role;
import org.beangle.security.blueprint.RoleMember;
import org.beangle.security.blueprint.User;
import org.beangle.security.blueprint.function.FuncPermission;
import org.beangle.security.blueprint.function.FuncResource;
import org.beangle.security.blueprint.function.service.internal.CacheableAuthorityManager;
import org.beangle.security.blueprint.nav.Menu;
import org.beangle.security.blueprint.nav.MenuProfile;
import org.beangle.security.core.authority.GrantedAuthorityBean;
import org.beangle.struts2.convention.route.Action;
/**
* 权限分配与管理响应类
*
* @author chaostone 2005-10-9
*/
public class PermissionAction extends SecurityActionSupport {
private CacheableAuthorityManager authorityManager;
/**
* 根据菜单配置来分配权限
*/
public String edit() {
Integer roleId = getId("role", Integer.class);
Role role = entityDao.get(Role.class, roleId);
User user = entityDao.get(User.class, getUserId());
put("manager", user);
List mngRoles = CollectUtils.newArrayList();
if (isAdmin()) {
mngRoles = entityDao.getAll(Role.class);
} else {
for (RoleMember m : user.getMembers()) {
if (m.isGranter()) mngRoles.add(m.getRole());
}
}
put("mngRoles", mngRoles);
List menuProfiles = securityHelper.getMenuService().getProfiles(role);
put("menuProfiles", menuProfiles);
MenuProfile menuProfile = securityHelper.getMenuService().getProfile(role, getInt("menuProfileId"));
if (null == menuProfile && !menuProfiles.isEmpty()) {
menuProfile = menuProfiles.get(0);
}
List