2021-06-27

spring boot 整合 shiro 权限框架

1.配置 pom 

	 <shiro.version>1.4.0</shiro.version>  <!--shiro start-->	 <dependency>	  <groupId>org.apache.shiro</groupId>	  <artifactId>shiro-core</artifactId>	  <version>${shiro.version}</version>	 </dependency>	 <dependency>	  <groupId>org.apache.shiro</groupId>	  <artifactId>shiro-web</artifactId>	  <version>${shiro.version}</version>	 </dependency>	 <dependency>	  <groupId>org.apache.shiro</groupId>	  <artifactId>shiro-ehcache</artifactId>	  <version>${shiro.version}</version>	 </dependency>	 <dependency>	  <groupId>org.apache.shiro</groupId>	  <artifactId>shiro-spring</artifactId>	  <version>${shiro.version}</version>	 </dependency>		<!--shiro end-->

  

2. MyShiroRealm.java

package org.fh.realm;import java.util.Collection;import java.util.HashSet;import org.apache.shiro.authc.*;import org.apache.shiro.authz.AuthorizationInfo;import org.apache.shiro.authz.SimpleAuthorizationInfo;import org.apache.shiro.realm.AuthorizingRealm;import org.apache.shiro.session.Session;import org.apache.shiro.subject.PrincipalCollection;import org.fh.service.system.UsersService;import org.fh.util.Const;import org.fh.util.Jurisdiction;import org.fh.entity.PageData;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Lazy; /** * 说明:Shiro身份认证 * 作者:FH * From:www.fhadmin.org */public class MyShiroRealm extends AuthorizingRealm {  @Autowired @Lazy private UsersService usersService; /**  * 登录认证  */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {  UsernamePasswordToken token = (UsernamePasswordToken)authenticationToken; 	//UsernamePasswordToken用于存放提交的登录信息	 PageData pd = new PageData();	 pd.put("USERNAME", token.getUsername());			try {				pd = usersService.findByUsername(pd);				if (pd != null){				 return new SimpleAuthenticationInfo(pd.getString("USERNAME"), pd.getString("PASSWORD"), getName());		  }			} catch (Exception e) {				return null;			}		return null; }	@Override	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {		String USERNAME = (String) super.getAvailablePrincipal(principals);		SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();		Session session = Jurisdiction.getSession();		Collection<String> shiroSet= new Has......

原文转载:http://www.shaoqun.com/a/832910.html

跨境电商:https://www.ikjzd.com/

insider:https://www.ikjzd.com/w/1786

友家快递:https://www.ikjzd.com/w/1341

zappos.com:https://www.ikjzd.com/w/330


1.配置pom <shiro.version>1.4.0</shiro.version><!--shirostart--> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <v
拍拍网:https://www.ikjzd.com/w/2205
好卖家:https://www.ikjzd.com/w/776
从"被拒绝"到"评分4.9"海尔如何通过电商平台Darty撬开欧洲大门?:https://www.ikjzd.com/articles/18101
服务商操作普通账户获取亚马逊vine绿标的原理:https://www.ikjzd.com/articles/18102
问题 小白个人怎样做跨境电商? 跨境电商怎么开始,前期准备什么?物流,货源怎么解决?:https://www.ikjzd.com/articles/18103
曝!亚马逊开始暂停供应商的账户,One Vendor真的要来了?:https://www.ikjzd.com/articles/18104
公在客厅里吃我的奶 奶好涨公帮帮我:http://lady.shaoqun.com/a/247972.html
猥琐老头系列辣文小说 妻子被老头玩弄的辣文:http://lady.shaoqun.com/m/a/247231.html
郭麒麟透露自己:6岁时,他和家人去吃饭,在厕所里遇到了一位40岁的叔叔:http://lady.shaoqun.com/a/389490.html
有些女人婚外情真的不止一次,这三个女人都说了原因:http://lady.shaoqun.com/a/389491.html
产后性生活记录:"我们俩在成功契合的当晚都哭了。":http://lady.shaoqun.com/a/389492.html
一个月"办事"几次正常?三个年龄阶段之间的频率存在差异:http://lady.shaoqun.com/a/389493.html

No comments:

Post a Comment