org.apache.shiro.authz.annotation.RequiresUser Java Examples
The following examples show how to use
org.apache.shiro.authz.annotation.RequiresUser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoryController.java From Shop-for-JavaWeb with MIT License | 6 votes |
@RequiresUser @ResponseBody @RequestMapping(value = "treeData") public List<Map<String, Object>> treeData(String module, @RequestParam(required=false) String extId, HttpServletResponse response) { response.setContentType("application/json; charset=UTF-8"); List<Map<String, Object>> mapList = Lists.newArrayList(); List<Category> list = categoryService.findByUser(true, module); for (int i=0; i<list.size(); i++){ Category e = list.get(i); if (extId == null || (extId!=null && !extId.equals(e.getId()) && e.getParentIds().indexOf(","+extId+",")==-1)){ Map<String, Object> map = Maps.newHashMap(); map.put("id", e.getId()); map.put("pId", e.getParent()!=null?e.getParent().getId():0); map.put("name", e.getName()); map.put("module", e.getModule()); mapList.add(map); } } return mapList; }
Example #2
Source File: AdminCategoryController.java From Shop-for-JavaWeb with MIT License | 6 votes |
/** * 分类树JSON */ @RequiresUser @ResponseBody @RequestMapping(value = "/treeData") public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) { response.setContentType("application/json; charset=UTF-8"); List<Map<String, Object>> mapList = Lists.newArrayList(); List<ShopCategory> list = categoryService.findFirstList(); for (int i=0; i<list.size(); i++){ ShopCategory e = list.get(i); if (extId == null || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf(","+extId+",") == -1)){ Map<String, Object> map = Maps.newHashMap(); map.put("id", e.getId()); map.put("pId", e.getParent() != null ? e.getParent().getId() : 0); map.put("name", e.getName()); mapList.add(map); } } return mapList; }
Example #3
Source File: UserResource.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@PUT @Path("/{userId}/password") @RequiresUser @RequiresAuthentication @RequiresPermissions("nexus:userschangepw:create") @Validate public void changePassword(@PathParam("userId") @NotNull final String userId, @NotNull @Valid final UserAccountPasswordXO xo) throws Exception { if (authTickets.redeemTicket(xo.getAuthToken())) { if (isAnonymousUser(userId)) { throw new Exception("Password cannot be changed for user ${userId}, since is marked as the Anonymous user"); } securitySystem.changePassword(userId, xo.getPassword()); } else { throw new IllegalAccessException("Invalid authentication ticket"); } }
Example #4
Source File: AuthorizationFilter.java From shiro-jersey with Apache License 2.0 | 5 votes |
private static AuthorizingAnnotationHandler createHandler(Annotation annotation) { Class<?> t = annotation.annotationType(); if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler(); else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler(); else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler(); else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler(); else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler(); else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t); }
Example #5
Source File: UserController.java From Mario with Apache License 2.0 | 5 votes |
@RequiresUser @RequestMapping(value = "profile", method = RequestMethod.POST) public String saveProfile(User user, RedirectAttributes redirectAttributes) { accountService.saveProfile(user); updateUserName(user.getName()); redirectAttributes.addFlashAttribute("message", "修改用户信息成功"); return "redirect:/account/user/profile"; }
Example #6
Source File: UserController.java From Mario with Apache License 2.0 | 5 votes |
@RequiresUser @RequestMapping(value = "profile", method = RequestMethod.GET) public String profile(Model model) { ShiroUser currentUser = (ShiroUser) SecurityUtils.getSubject().getPrincipal(); User user = accountService.getUser(currentUser.getId()); model.addAttribute("user", user); return "account/profile"; }
Example #7
Source File: AuthorizationFilter.java From shiro-jersey with Apache License 2.0 | 5 votes |
private static AuthorizingAnnotationHandler createHandler(Annotation annotation) { Class<?> t = annotation.annotationType(); if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler(); else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler(); else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler(); else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler(); else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler(); else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t); }
Example #8
Source File: IndexAdminController.java From pybbs with GNU Affero General Public License v3.0 | 5 votes |
@RequiresUser @GetMapping({"/", "/index"}) public String index(Model model) { // 查询当天新增话题 model.addAttribute("topic_count", topicService.countToday()); // 查询当天新增标签 model.addAttribute("tag_count", tagService.countToday()); // 查询当天新增评论 model.addAttribute("comment_count", commentService.countToday()); // 查询当天新增用户 model.addAttribute("user_count", userService.countToday()); // 获取操作系统的名字 model.addAttribute("os_name", System.getProperty("os.name")); // 内存 int kb = 1024; OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); // 总的物理内存 long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb; //已使用的物理内存 long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb.getFreePhysicalMemorySize()) / kb; // 获取系统cpu负载 double systemCpuLoad = osmxb.getSystemCpuLoad(); // 获取jvm线程负载 double processCpuLoad = osmxb.getProcessCpuLoad(); model.addAttribute("totalMemorySize", totalMemorySize); model.addAttribute("usedMemory", usedMemory); model.addAttribute("systemCpuLoad", systemCpuLoad); model.addAttribute("processCpuLoad", processCpuLoad); return "admin/index"; }
Example #9
Source File: FreezeResource.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @RequiresUser @GET public ReadOnlyState get() { // provide extra detail when current user has access to settings return new ReadOnlyState(freezeService.currentFreezeRequests(), securityHelper.allPermitted(READ_SETTINGS_PERMISSION)); }
Example #10
Source File: UserResource.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@PUT @RequiresUser @RequiresAuthentication @Validate public void updateAccount(@NotNull @Valid final UserAccountXO xo) throws UserNotFoundException, NoSuchUserManagerException { User user = getCurrentUser(); user.setFirstName(xo.getFirstName()); user.setLastName(xo.getLastName()); user.setEmailAddress(xo.getEmail()); securitySystem.updateUser(user); }
Example #11
Source File: UserResource.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Retrieves user account (logged in user info). * * @return current logged in user account. */ @GET @RequiresUser public UserAccountXO readAccount() throws UserNotFoundException { return convert(getCurrentUser()); }
Example #12
Source File: StatusResource.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @RequiresUser public StatusXO get() { StatusXO result = new StatusXO(); result.setVersion(applicationVersion.getVersion()); result.setEdition(applicationVersion.getEdition()); return result; }
Example #13
Source File: RenderController.java From OneBlog with GNU General Public License v3.0 | 5 votes |
@RequiresUser @BussinessLog("进入搬运工页面") @GetMapping("/remover") public ModelAndView remover(Model model) { model.addAttribute("exitWayList", ExitWayEnum.values()); model.addAttribute("spiderConfig", HunterConfigTemplate.configTemplate.toJSONString()); model.addAttribute("platforms", Platform.values()); return ResultUtil.view("laboratory/remover"); }
Example #14
Source File: RenderController.java From OneBlog with GNU General Public License v3.0 | 4 votes |
@RequiresUser @BussinessLog("进入编辑器测试用例页面") @GetMapping("/editor") public ModelAndView editor(Model model) { return ResultUtil.view("other/editor"); }
Example #15
Source File: HandlerCreateVisitor.java From tapestry-security with Apache License 2.0 | 4 votes |
@Override public void visitRequiresUser(RequiresUser annotation) { handler = new UserAnnotationHandler(); }
Example #16
Source File: AlphaService.java From tapestry-security with Apache License 2.0 | 4 votes |
@RequiresUser String invokeRequiresUser();
Example #17
Source File: AdminIndexController.java From dts-shop with GNU Lesser General Public License v3.0 | 4 votes |
@RequiresUser @RequestMapping("/user") public Object user() { return ResponseUtil.ok("hello world, this is admin service"); }
Example #18
Source File: MethodAnnotationCaster.java From tapestry-security with Apache License 2.0 | 3 votes |
public void accept(MethodAnnotationCasterVisitor visitor, Annotation annotation) { if (annotation instanceof RequiresPermissions) { visitor.visitRequiresPermissions((RequiresPermissions) annotation); } else if (annotation instanceof RequiresRoles) { visitor.visitRequiresRoles((RequiresRoles) annotation); } else if (annotation instanceof RequiresUser) { visitor.visitRequiresUser((RequiresUser) annotation); } else if (annotation instanceof RequiresGuest) { visitor.visitRequiresGuest((RequiresGuest) annotation); } else if (annotation instanceof RequiresAuthentication) { visitor.visitRequiresAuthentication((RequiresAuthentication) annotation); } else { visitor.visitNotFound(); } }
Example #19
Source File: RestCommentController.java From OneBlog with GNU General Public License v3.0 | 2 votes |
/** * 正在审核的 * * @param comment * @return */ @RequiresUser @PostMapping("/listVerifying") public ResponseVO listVerifying(Comment comment) { return ResultUtil.success(null, commentService.listVerifying(10)); }