<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>用户角色验证授权 on 知识铺的博客</title>
    <link>https://index.zshipu.com/geek001/tags/%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2%E9%AA%8C%E8%AF%81%E6%8E%88%E6%9D%83/</link>
    <description>Recent content in 用户角色验证授权 on 知识铺的博客</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-CN</language>
    <lastBuildDate>Sun, 28 Apr 2024 06:34:08 +0000</lastBuildDate>
    <atom:link href="https://index.zshipu.com/geek001/tags/%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2%E9%AA%8C%E8%AF%81%E6%8E%88%E6%9D%83/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>实现基于Scala的Shiro用户角色验证和授权</title>
      <link>https://index.zshipu.com/geek001/post/20240428/%E5%AE%9E%E7%8E%B0%E5%9F%BA%E4%BA%8EScala%E7%9A%84Shiro%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2%E9%AA%8C%E8%AF%81%E5%92%8C%E6%8E%88%E6%9D%83--%E7%9F%A5%E8%AF%86%E9%93%BA/</link>
      <pubDate>Sun, 28 Apr 2024 06:34:08 +0000</pubDate>
      <guid>https://index.zshipu.com/geek001/post/20240428/%E5%AE%9E%E7%8E%B0%E5%9F%BA%E4%BA%8EScala%E7%9A%84Shiro%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2%E9%AA%8C%E8%AF%81%E5%92%8C%E6%8E%88%E6%9D%83--%E7%9F%A5%E8%AF%86%E9%93%BA/</guid>
      <description>代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 public class UserRealm extends Pac4jRealm(){ @Override public AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { System.out.println(&amp;#34;Onece&amp;#34;); Set&amp;lt;String&amp;gt; roles=new HashSet()&amp;lt;&amp;gt;; roles.add(&amp;#34;admin&amp;#34;); SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); authorizationInfo.setRoles(roles); return authorizationInfo ; } 1 2 3 4 5 6 @RequestMapping(&amp;#34;/hello2&amp;#34;) @ResponseBody public String hello2() { SecurityUtils.getSubject().checkRoles(&amp;#34;user&amp;#34;); return &amp;#34;success&amp;#34;; }</description>
    </item>
  </channel>
</rss>
