當前位置: 首頁>>代碼示例>>Java>>正文


Java RequiresPermissions類代碼示例

本文整理匯總了Java中org.apache.shiro.authz.annotation.RequiresPermissions的典型用法代碼示例。如果您正苦於以下問題:Java RequiresPermissions類的具體用法?Java RequiresPermissions怎麽用?Java RequiresPermissions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequiresPermissions類屬於org.apache.shiro.authz.annotation包,在下文中一共展示了RequiresPermissions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: code

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 生成代碼
 */
@RequestMapping("/code")
@RequiresPermissions("sys:generator:code")
public void code(HttpServletRequest request, HttpServletResponse response) throws IOException{
	String[] tableNames = new String[]{};
	//獲取表名,不進行xss過濾
	HttpServletRequest orgRequest = XssHttpServletRequestWrapper.getOrgRequest(request);
	String tables = orgRequest.getParameter("tables");
	tableNames = JSON.parseArray(tables).toArray(tableNames);
	
	byte[] data = sysGeneratorService.generatorCode(tableNames);
	
	response.reset();  
       response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\"");  
       response.addHeader("Content-Length", "" + data.length);  
       response.setContentType("application/octet-stream; charset=UTF-8");  
 
       IOUtils.write(data, response.getOutputStream());  
}
 
開發者ID:guolf,項目名稱:pds,代碼行數:22,代碼來源:SysGeneratorController.java

示例2: delete

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 刪除用戶
 */
@SysLog("刪除用戶")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public Result delete(@RequestBody Long[] userIds) {
    if (ArrayUtils.contains(userIds, 1L)) {
        return Result.error("係統管理員不能刪除");
    }

    if (ArrayUtils.contains(userIds, getUserId())) {
        return Result.error("當前用戶不能刪除");
    }

    try {
        sysUserService.deleteBatch(userIds);
    } catch (Exception e) {
        logger.error("刪除用戶異常", e);
        return Result.error("刪除用戶異常");
    }

    return Result.ok();
}
 
開發者ID:davichi11,項目名稱:my-spring-boot-project,代碼行數:25,代碼來源:SysUserController.java

示例3: editPermission

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 編輯資源
 * @param id 資源的id,Permission.id 
 */
@RequiresPermissions("adminRolePermission")
@RequestMapping("editPermission")
public String editPermission(@RequestParam(value = "id", required = true) int id,Model model, HttpServletRequest request){
	if(id>0){
		Permission permission = sqlService.findById(Permission.class, id);
		if(permission!=null){
			String parentPermissionDescription="頂級";
			if(permission.getParentId()>0){
				Permission parentPermission = sqlService.findById(Permission.class, permission.getParentId());
				parentPermissionDescription = parentPermission.getName() +","+ parentPermission.getDescription();
			}
			
			ActionLogCache.insert(request, permission.getId(), "進入修改資源Permission頁麵", "所屬上級:"+parentPermissionDescription);
			
			model.addAttribute("permission", permission);
			model.addAttribute("parentPermissionDescription", parentPermissionDescription);
			return "iw/admin/role/permission";
		}
	}
	return error(model, "出錯,參數錯誤");
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:26,代碼來源:RoleAdminController_.java

示例4: saveExportModel

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 保存導出的模型
 * @param modelName 模型名稱
 * @param cnames 中文字段集合
 * @param enames 英文字段集合
 * @return
 */
@ResponseBody
@RequiresPermissions("system:export:add")
@MumuLog(name = "添加導出模型",operater = "POST")
@RequestMapping(value="/add",method=RequestMethod.POST)
public ResponseEntity saveExportModel(String modelName, String cnames, String enames){
	SysExportModel exportModel=new SysExportModel();
	exportModel.setCnames(cnames);
	exportModel.setEnames(enames);
	exportModel.setModelName(modelName);
	try {
		exportModelService.addExportModel(exportModel);
		return new ResponseEntity(200,"導出模型保存成功",null);
	} catch (Exception e) {
		log.error(e);
		return new ResponseEntity(500, "保存模型出現異常", null);
	}
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:25,代碼來源:SystemExportModelController.java

示例5: update

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
@ApiOperation(value = "修改係統")
@RequiresPermissions("upms:system:update")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable("id") int id, UpmsSystem upmsSystem) {
	ComplexResult result = FluentValidator.checkAll()
			.on(upmsSystem.getTitle(), new LengthValidator(1, 20, "標題"))
			.on(upmsSystem.getName(), new LengthValidator(1, 20, "名稱"))
			.doValidate()
			.result(ResultCollectors.toComplex());
	if (!result.isSuccess()) {
		return new UpmsResult(UpmsResultConstant.INVALID_LENGTH, result.getErrors());
	}
	upmsSystem.setSystemId(id);
	int count = upmsSystemService.updateByPrimaryKeySelective(upmsSystem);
	return new UpmsResult(UpmsResultConstant.SUCCESS, count);
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:18,代碼來源:UpmsSystemController.java

示例6: updateTask

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
@PostMapping
@ApiOperation(value = "新增任務")
@RequiresPermissions("sys.task.scheduled.update")
public Object updateTask(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	Assert.notNull(scheduled.getJobType(), "JOBTYPE");
	Assert.notNull(scheduled.getTaskType(), "TASKTYPE");
	Assert.notNull(scheduled.getTargetObject(), "TARGETOBJECT");
	Assert.notNull(scheduled.getTargetMethod(), "TARGETMETHOD");
	Assert.notNull(scheduled.getTaskCron(), "TASKCRON");
	Assert.notNull(scheduled.getTaskDesc(), "TASKDESC");
	if (TaskType.dubbo.equals(scheduled.getTaskType())) {
		Assert.notNull(scheduled.getTargetSystem(), "TARGETSYSTEM");
	}
	Parameter parameter = new Parameter(getService(), "updateTask").setModel(scheduled);
	provider.execute(parameter);
	return setSuccessModelMap(modelMap);
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:20,代碼來源:ScheduledController.java

示例7: delete

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 刪除
 */
@SysLog("刪除菜單")
@RequestMapping("/delete")
@RequiresPermissions("sys:menu:delete")
public R delete(long menuId){
	if(menuId <= 30){
		return R.error("係統菜單,不能刪除");
	}

	//判斷是否有子菜單或按鈕
	List<SysMenuEntity> menuList = sysMenuService.queryListParentId(menuId);
	if(menuList.size() > 0){
		return R.error("請先刪除子菜單或按鈕");
	}

	sysMenuService.deleteBatch(new Long[]{menuId});
	
	return R.ok();
}
 
開發者ID:zhaoqicheng,項目名稱:renren-fast,代碼行數:22,代碼來源:SysMenuController.java

示例8: groupEdit

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 編輯用戶組
 * @param groupId 用戶組id
 * @return
 */
@RequiresPermissions("system:group:edit")
@RequestMapping(value="/edit/{groupId}",method=RequestMethod.GET)
public String groupEdit(@PathVariable String groupId,HttpServletRequest request){
	SysGroup group=groupService.getSysGroupById(groupId);
	request.setAttribute("group", group);
	
	List<SysOrganize> organizes = organizeService.querySysOrganizeByCondition(null);
	List<NodeUtil.NodeBean> nodeBeans = new ArrayList<NodeUtil.NodeBean>();
	for (SysOrganize org : organizes) {
		nodeBeans.add(new NodeUtil.NodeBean(String.valueOf(org.getOrgId()), String.valueOf(org.getParentOrgId()), org));
	}
	List<T> organizesList = NodeUtil.iterator(nodeBeans, "﹎﹎", "orgName");
	request.setAttribute("organizes", organizesList);
	return "system/group/edit";
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:21,代碼來源:SystemGroupController.java

示例9: userRole

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
@ApiOperation(value = "修改用戶角色")
@PostMapping(value = "/user/update/role")
@RequiresPermissions("sys.permisson.userRole.update")
public Object userRole(ModelMap modelMap, @RequestBody List<SysUserRole> list) {
    Long userId = null;
    Long currentUserId = getCurrUser();
    for (SysUserRole sysUserRole : list) {
        if (sysUserRole.getUserId() != null) {
            if (userId != null && sysUserRole.getUserId() != null
                && userId.longValue() != sysUserRole.getUserId()) {
                throw new IllegalParameterException("參數錯誤.");
            }
            userId = sysUserRole.getUserId();
        }
        sysUserRole.setCreateBy(currentUserId);
        sysUserRole.setUpdateBy(currentUserId);
        sysUserRole.setCreateTime(new Date());
        sysUserRole.setUpdateTime(new Date());
    }
    Parameter parameter = new Parameter(getService(), "updateUserRole").setList(list);
    logger.info("{} execute updateUserRole start...", parameter.getNo());
    provider.execute(parameter);
    logger.info("{} execute updateUserRole end.", parameter.getNo());
    return setSuccessModelMap(modelMap);
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:26,代碼來源:SysAuthorizeController.java

示例10: list

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
@ApiOperation(value = "類目列表")
@RequiresPermissions("cms:category:read")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(
		@RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
		@RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
		@RequestParam(required = false, value = "sort") String sort,
		@RequestParam(required = false, value = "order") String order) {
	CmsCategoryExample cmsCategoryExample = new CmsCategoryExample();
	if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) {
		cmsCategoryExample.setOrderByClause(sort + " " + order);
	}
	List<CmsCategory> rows = cmsCategoryService.selectByExampleForOffsetPage(cmsCategoryExample, offset, limit);
	long total = cmsCategoryService.countByExample(cmsCategoryExample);
	Map<String, Object> result = new HashMap<>();
	result.put("rows", rows);
	result.put("total", total);
	return result;
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:21,代碼來源:CmsCategoryController.java

示例11: updateExportModel

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 保存編輯的模型
 * @param modelId 模型id
 * @param cnames 中文字段集合
 * @param enames 英文字段集合
 * @param request
 * @return
 */
@ResponseBody
@RequiresPermissions("system:export:edit")
@MumuLog(name = "編輯導出模型",operater = "POST")
@RequestMapping(value="/edit",method=RequestMethod.PUT)
public ResponseEntity updateExportModel(int modelId,String cnames,String enames,HttpServletRequest request){
	SysExportModel exportModel=new SysExportModel();
	exportModel.setCnames(cnames);
	exportModel.setEnames(enames);
	exportModel.setModelId(modelId);
	try {
		exportModelService.updateSysExportModel(exportModel);
		return new ResponseEntity(200, "導出模型編輯成功", null);
	} catch (Exception e) {
		log.error(e);
		return new ResponseEntity(500, "更新模型出現異常", null);
	}
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:26,代碼來源:SystemExportModelController.java

示例12: update

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
@PostMapping
@ApiOperation(value = "修改用戶信息")
@RequiresPermissions("sys.base.user.update")
public Object update(ModelMap modelMap, @RequestBody SysUser param) {
	Assert.isNotBlank(param.getAccount(), "ACCOUNT");
	Assert.length(param.getAccount(), 3, 15, "ACCOUNT");
	if (param.getId() != null) {
		if (param.getEnable() == null) {
			param.setEnable(1);
		}
		Parameter parameter = new Parameter(getService(), "queryById").setId(param.getId());
		SysUser user = (SysUser) provider.execute(parameter).getModel();
		Assert.notNull(user, "USER", param.getId());
		if (StringUtils.isNotBlank(param.getPassword())) {
			if (!param.getPassword().equals(user.getPassword())) {
				param.setPassword(SecurityUtil.encryptPassword(param.getPassword()));
			}
		}
	} else if (StringUtils.isNotBlank(param.getPassword())) {
		param.setPassword(SecurityUtil.encryptPassword(param.getPassword()));
	}
	return super.update(modelMap, param);
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:24,代碼來源:SysUserController.java

示例13: siteUpdatePassword

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 代理商給其下的某個站點更改密碼
 * @param userid 要更改密碼的user.id
 * @param newPassword 要更改上的新密碼
 */
@RequiresPermissions("agencySiteUpdatePassword")
@RequestMapping("siteUpdatePassword")
@ResponseBody
public BaseVO siteUpdatePassword(HttpServletRequest request,
		@RequestParam(value = "userid", required = true) int userid,
		@RequestParam(value = "newPassword", required = true) String newPassword){
	User user = sqlService.findById(User.class, userid);
	if(user == null){
		return error("用戶不存在");
	}
	//判斷是否是其直屬下級
	if(user.getReferrerid() - getMyAgency().getUserid() != 0){
		return error("要更改密碼的網站不是您的直屬下級,操作失敗");
	}
	
	return userService.updatePassword(userid, newPassword);
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:23,代碼來源:AgencyUserController.java

示例14: groupView

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 查看用戶組詳情
 * @param groupId 用戶組id
 * @return
 */
@RequiresPermissions("system:group:view")
@RequestMapping(value="/view/{groupId}",method=RequestMethod.GET)
public String groupView(@PathVariable String groupId,HttpServletRequest request){
	SysGroup group=groupService.getSysGroupById(groupId);
	request.setAttribute("group", group);

	List<SysOrganize> organizes = organizeService.querySysOrganizeByCondition(null);
	List<NodeUtil.NodeBean> nodeBeans = new ArrayList<NodeUtil.NodeBean>();
	for (SysOrganize org : organizes) {
		nodeBeans.add(new NodeUtil.NodeBean(String.valueOf(org.getOrgId()), String.valueOf(org.getParentOrgId()), org));
	}
	List<T> organizesList = NodeUtil.iterator(nodeBeans, "﹎﹎", "orgName");
	request.setAttribute("organizes", organizesList);
	return "system/group/view";
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:21,代碼來源:SystemGroupController.java

示例15: subAgencyList

import org.apache.shiro.authz.annotation.RequiresPermissions; //導入依賴的package包/類
/**
 * 我的的下級代理商列表
 */
@RequiresPermissions("agencySubAgencyList")
@RequestMapping("subAgencyList")
public String subAgencyList(HttpServletRequest request, Model model){
	Agency agency = getMyAgency();
	
	Sql sql = new Sql(request);
	sql.setSearchTable("agency");
	sql.appendWhere("agency.parent_id = "+agency.getId());
	sql.setSearchColumn(new String[]{"name","phone"});
	int count = sqlService.count("agency", sql.getWhere());
	Page page = new Page(count, G.PAGE_WAP_NUM, request);
	sql.setSelectFromAndPage("SELECT agency.*, user.username FROM agency,user", page);
	sql.appendWhere("user.id = agency.userid");
	sql.setOrderByField(new String[]{"id","expiretime","addtime"});
	List<Map<String, Object>> list = sqlService.findMapBySql(sql);
	AliyunLog.addActionLog(0, "查看我的下級代理列表");
	
	model.addAttribute("list", list);
	model.addAttribute("page", page);
	return "agency/subAgencyList";
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:25,代碼來源:AgencyUserController.java


注:本文中的org.apache.shiro.authz.annotation.RequiresPermissions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。