你的位置:首页 > 软件开发 > Java > Apache Shiro 使用手册(三)Shiro 授权

Apache Shiro 使用手册(三)Shiro 授权

发布时间:2015-06-24 00:00:26
授权即访问控制,它将判断用户在应用程序中对资源是否拥有相应的访问权限。 如,判断一个用户有查看页面的权限,编辑数据的权限,拥有某一按钮的权限,以及是否拥有打印的权限等等。一、授权的三要素授权有着三个核心元素:权限、角色和用户。权限权限是Apache Shiro安全机制最核心的元素 ...

授权即访问控制,它将判断用户在应用程序中对资源是否拥有相应的访问权限。 一、授权的三要素授权有着三个核心元素:权限、角色和用户。权限权限声明及粒度角色二、授权实现Shiro支持三种方式实现授权过程:1.1基于传统角色授权实现类似基于对象的实现相关方法,基于字符串的实现相关方法:基于权限对象的断言实现相关的注解:@ RequiresPermissions@ RequiresUser3、基于JSP  TAG的授权实现

  1. <shiro:guest>  
  2.     Hi there!  Please <a href="login.jsp">Login</a> or <a href="signup.jsp">Signup</a> today!  
  3. </shiro:guest>  
  1. <shiro:user>  
  2.     Welcome back John!  Not John? Click <a href="login.jsp">here<a> to login.  
  3. </shiro:user>  
  1. <shiro:authenticated>  
  2.     <a href="updateAccount.jsp">Update your contact information</a>.  
  3. </shiro:authenticated>  
  1. <shiro:notAuthenticated>  
  2.     Please <a href="login.jsp">login</a> in order to update your credit card information.  
  3. </shiro:notAuthenticated>  
  1. Hello, <shiro:principal/>, how are you today?  
  1. <shiro:hasRole name="administrator">  
  2.     <a href="admin.jsp">Administer the system</a>  
  3. </shiro:hasRole>  
  1. <shiro:lacksRole name="administrator">  
  2.     Sorry, you are not allowed to administer the system.  
  3. </shiro:lacksRole>  
  1. <shiro:hasAnyRoles name="developer, project manager, administrator">  
  2.     You are either a developer, project manager, or administrator.  
  3. </shiro:lacksRole>  
  1. <shiro:hasPermission name="user:create">  
  2.     <a href="createUser.jsp">Create a new User</a>  
  3. </shiro:hasPermission>  
  1. <shiro:hasPermission name="user:create">  
  2.     <a href="createUser.jsp">Create a new User</a>  
  3. </shiro:hasPermission>  
三、Shiro授权的内部处理机制当使用多个Realm时,不同于认证策略处理方式,授权处理过程中:

原标题:Apache Shiro 使用手册(三)Shiro 授权

关键词:Apache

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录