当前位置: 首页 > news >正文

毕业设计平台杭州seo博客有哪些

毕业设计平台,杭州seo博客有哪些,wow做宏的网站,自己怎么做个网站1 Shiro 什么是 Shiro 官网: http://shiro.apache.org/ 是一款主流的 Java 安全框架,不依赖任何容器,可以运行在 Java SE 和 Java EE 项目中,它的主要作用是对访问系统的用户进行身份认证、 授权、会话管理、加密等操作。 …
1 Shiro
什么是 Shiro
官网: http://shiro.apache.org/
是一款主流的 Java 安全框架,不依赖任何容器,可以运行在 Java SE
Java EE 项目中,它的主要作用是对访问系统的用户进行身份认证、
授权、会话管理、加密等操作。
Shiro 就是用来解决安全管理的系统化框架。
2 Shiro 核心组件
用户、角色、权限 会给角色赋予权限,给用户赋予角色
1 UsernamePasswordToken Shiro 用来封装用户登录信息,使用 用户的登录信息来创建令牌 Token
2 SecurityManager Shiro 的核心部分,负责安全认证和授权。
3 Suject Shiro 的一个抽象概念,包含了用户信息。
4 Realm ,开发者自定义的模块,根据项目的需求,验证和授权的逻 辑全部写在 Realm 中。
5 AuthenticationInfo ,用户的角色信息集合,认证时使用。
6 AuthorzationInfo ,角色的权限信息集合,授权时使用。
7 DefaultWebSecurityManager ,安全管理器,开发者自定义的 Realm 需要注入到 DefaultWebSecurityManager 进行管理才能生 效。
8 ShiroFilterFactoryBean ,过滤器工厂, Shiro 的基本运行机制是开 发者定制规则,Shiro 去执行,具体的执行操作就是由 ShiroFilterFactoryBean 创建的一个个 Filter 对象来完成。
Shiro 的运行机制如下图所示。
3 Spring Boot 整合 Shiro
1 、创建 Spring Boot 应用,集成 Shiro 及相关组件, pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>springboot-shiro</artifactId><version>0.1.0</version><properties><java.version>11</java.version><spring.boot.version>2.5.4</spring.boot.version><shiro.version>1.7.1</shiro.version></properties><dependencies><!-- Spring Boot Starter Web --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>${spring.boot.version}</version></dependency><!-- Shiro Starter --><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring-boot-starter</artifactId><version>${shiro.version}</version></dependency><!-- Other Dependencies --><!-- Add other dependencies here if needed --></dependencies><build><plugins><!-- Maven Compiler Plugin --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>${java.version}</source><target>${java.version}</target></configuration></plugin><!-- Spring Boot Maven Plugin --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring.boot.version}</version></plugin></plugins></build></project>

2 、自定义 Shiro 过滤器
import sun.net.www.protocol.http.AuthenticationInfo;public class AccoutRealm extends AuthorizingRealm {@Autowiredprivate AccountService accountService;/*** 授权** @param principalCollection* @return*/@Overrideprotected AuthorizationInfodoGetAuthorizationInfo(PrincipalCollection principalCollection) {return null;}/*** 认证** @param authenticationToken* @return* @throws AuthenticationException*/@Overrideprotected AuthenticationInfodoGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;Account account = accountService.findByUsername(token.getUsername());if (account != null) {return new SimpleAuthenticationInfo(account, account.getPassword(), getName());}return null;}
}
3、配置类 
@Configuration
public class ShiroConfig {
@Bean
public ShiroFilterFactoryBean
shiroFilterFactoryBean(@Qualifier("securityManager")
DefaultWebSecurityManager securityManager){
ShiroFilterFactoryBean factoryBean = new
ShiroFilterFactoryBean();
factoryBean.setSecurityManager(securityManager);
return factoryBean;
}
@Bean
public DefaultWebSecurityManager
securityManager(@Qualifier("accoutRealm") AccoutRealm
accoutRealm){
DefaultWebSecurityManager manager = new
DefaultWebSecurityManager();
manager.setRealm(accoutRealm);
return manager;
}
@Bean
public AccoutRealm accoutRealm(){
return new AccoutRealm();
}
}
编写认证和授权规则:
认证过滤器 anon :无需认证。
authc :必须认证。
authcBasic :需要通过 HTTPBasic 认证。
user :不一定通过认证,只要曾经被 Shiro 记录即可,比如:记住我。
授权过滤器
perms :必须拥有某个权限才能访问。
role :必须拥有某个角色才能访问。
port :请求的端口必须是指定值才可以。
rest :请求必须基于 RESTful POST PUT GET DELETE
ssl :必须是安全的 URL 请求,协议 HTTPS
创建 3 个页面, main.html manage.html administrator.html
访问权限如下:
1 、必须登录才能访问 main.html
2 、当前用户必须拥有 manage 授权才能访问 manage.html
3 、当前用户必须拥有 administrator 角色才能访问
administrator.html
Shiro 整合 Thymeleaf
1 pom.xml 引入依赖
<dependency>
<groupId> com.github.theborakompanioni </groupId>
<artifactId> thymeleaf-extras-shiro </artifactId>
<version> 2.0.0 </version>
</dependency>
2 、配置类添加 ShiroDialect
@Bean
public ShiroDialect shiroDialect (){
return new ShiroDialect ();
}
3 index.html
<!DOCTYPE html>
<html lang = "en" xmlns:th = "http://www.thymeleaf.org"
xmlns:shiro = "http://www.thymeleaf.org/thymeleaf-extras
shiro" >
<head>
<meta charset = "UTF-8" >
<title> Title </title>
<link rel = "shortcut icon" href = "#" />
</head>
<body>
<h1> index </h1>
<div th:if = "${session.account != null}" >
<span th:text = "${session.account.username}+'
迎回来! '" ></span><a href = "/logout" > 退出 </a>
</div>
<a href = "/main" > main </a> <br/>
<div shiro:hasPermission = "manage" >
<a href = "manage" > manage </a> <br/>
</div>
<div shiro:hasRole = "administrator" >
<a href = "/administrator" > administrator </a>
</div>
</body> </html>
数据库
http://www.rdtb.cn/news/13749.html

相关文章:

  • 韩国做美食网站有哪些德州网站建设优化
  • html5可以做网站吗英雄联盟更新公告最新
  • 网站组织结构图广告招商
  • 自已做的网站怎么做域名解析免费的自助建站
  • 自己做的网站被举报违反广告法搜索引擎优化期末考试答案
  • 深圳网站开发制作网络优化这个行业怎么样
  • 做自媒体怎么在其它网站搬运内容淘宝seo搜索优化工具
  • 金融培训网站源码百度软件
  • 巩义网站推广怎么做营销策划思路
  • 企业网站建设经验分享百度学术论文查重官网入口
  • 疯狗做网站网推公司
  • 做vi设计的网站百度不收录网站怎么办
  • 深圳网站制作公司平台优化营商环境存在问题及整改措施
  • 最美珠海app下载seo综合查询网站
  • 网站建设方案书 备案创建网站教程
  • 网站怎么开通微信支付竞价推广托管多少钱
  • 学校网站注重服务平台建设网络营销的特点不包括
  • 用java做网站的流程百度游戏中心app
  • 赣州哪里做网站google站长工具
  • wordpress媒体库整理泰安网站推广优化
  • 设计公司网站源码2345电脑版网址导航
  • 网站建设图片百度网址安全检测中心
  • 免费企业网站开源系统网络推广外包想手机蛙软件
  • 网站建设销售顾问开场白找精准客户的app
  • 做地方门户网站怎样陕西新闻今日头条
  • wordpress摄影模板seo工程师招聘
  • ceo是什么职位什么工作西安seo专员
  • 专业做网站安全的sine安广州谷歌seo公司
  • 深圳企业公司做网站长尾关键词查询
  • 网站统一做301seo职位描述