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

临沂做网站公司做seo要投入什么

临沂做网站公司,做seo要投入什么,垂直类网站怎么做推广,wordpress首页无法看到后台登录1、概述 Apache Shiro 是一个功能强大且易于使用的 Java 安全(权限)框架。借助 Shiro 您可以快速轻松地保护任何应用程序一一从最小的移动应用程序到最大的 Web 和企业应用程序。 作用:Shiro可以帮我们完成 :认证、授权、加密、会话管理、与 Web 集成、…

1、概述

Apache Shiro 是一个功能强大且易于使用的 Java 安全(权限)框架。借助 Shiro 您可以快速轻松地保护任何应用程序一一从最小的移动应用程序到最大的 Web 和企业应用程序。

作用:Shiro可以帮我们完成 :认证授权、加密、会话管理、与 Web 集成、缓存等。

2、Shiro 与 SpringSecurity 的对比

  • 1、Spring Security 基于 pring 开发,项目若使用 Spring 作为基础,配合 SpringSecurity 做权限更加方便,而 Shiro需要和 Spring 进行整合开发;
  • 2、Spring Security 功能比 Shiro 更加丰富些,例如安全维护方面;
  • 3、Spring Security 社区资源相对比 Shiro 更加丰富:;
  • 4、Shiro的配置和使用比较简单,Spring Security 上手复杂些;
  • 5、Shiro 依赖性低,不需要任何框架和容器,可以独立运行.Spring Security 依赖Spring容器;
  • 6、shiro 不仅仅可以使用在 web 中,它可以工作在任何应用环境中。在集群会话时 Shiro最重要的一个好处或许就是它的会话是独立于容器的;

3、Shiro核心架构

 

 

Subject即主体,外部应用与subject进行交互,subject记录了当前的操作用户,将用户的概念理解为当前操作的主体。外部程序通过subject进行认证授权,而subject是通过SecurityManager安全管理器进行认证授权

SecurityManager即安全管理器,对全部的subject进行安全管理,它是shiro的核心,负责对所有的subject进行安全管理。通过SecurityManager可以完成subject的认证、授权等,实质上SecurityManager是通过Authenticator进行认证,通过Authorizer进行授权,通过SessionManager进行会话管理等

SecurityManager是一个接口,继承了Authenticator, Authorizer, SessionManager这三个接口

Authenticator即认证器,对用户身份进行认证,Authenticator是一个接口,shiro提供ModularRealmAuthenticator实现类,通过ModularRealmAuthenticator基本上可以满足大多数需求,也可以自定义认证器

Authorizer即授权器,用户通过认证器认证通过,在访问功能时需要通过授权器判断用户是否有此功能的操作权限

Realm即领域,相当于datasource数据源,securityManager进行安全认证需要通过Realm获取用户权限数据,比如:如果用户身份数据在数据库那么realm就需要从数据库获取用户身份信息

sessionManager即会话管理,shiro框架定义了一套会话管理,它不依赖web容器的session,所以shiro可以使用在非web应用上,也可以将分布式应用的会话集中在一点管理,此特性可使它实现单点登录

SessionDAO即会话dao,是对session会话操作的一套接口,比如要将session存储到数据库,可以通过jdbc将会话存储到数据库

CacheManager即缓存管理,将用户权限数据存储在缓存,这样可以提高性能Cryptography
Cryptography即密码管理,shiro提供了一套加密/解密的组件,方便开发。比如提供常用的散列、加/解密等功能。

token 

1、token定义:服务端生成的一串字符串,可以解决频繁登录的问题
作为客户端进行请求的一个令牌:

  • 第一次登录后,服务器生成一个token返回给客户端;
  • 客户端只需要带上token来请求数据即可,无需再次带上用户名和密码;

2、目的:为了减轻服务器的压力,减少频繁的查询数据库,使服务器更加健壮

4、Shiro的登录认证

1.创建数据库并创建用户表;
2.创建项目病配置ssm,完成根据用户名查询用户信息;
3.创建自定义Realm,继承AuthorizingRealm,使用mybtais查询数据库的盐值和密码,交给shiro进行验证;

流程

1.数据库与表创建

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (`uid` int(11) NOT NULL AUTO_INCREMENT,`uname` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,`pwd` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,`sex` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`address` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`state` int(2) DEFAULT NULL,`salt` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,PRIMARY KEY (`uid`) USING BTREE,UNIQUE INDEX `uname`(`uname`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, 'admin', '727d8b2b4c59366d7ace58d4eda4cfee', '女', '河南洛阳', 1, '9C2AB20283F9450389330033D64686DD');
INSERT INTO `user` VALUES (2, 'zs', '83f12ba7c4357b87167e240a22c15248', '男', '河南郑州', 1, '262F995823C94D1CAE7596B47E8AB657');select * from user

2.创建模块项目,使用maven+ssm+shiro

 3.搭建ssm框架,编写根据用户名查询用户信息的三层架构

shiro在spring.xml中的配置

 dao层 

@Repository
public interface UserDao {@Select("select * from user where uname = #{uname}")User selectByName(String uname);
}

 service层

public interface UserService {User selectByName(String uname);
}

实现类 

@Service
public class UserServiceImpl implements UserService {@AutowiredUserDao userDao;@Overridepublic User selectByName(String uname) {return userDao.selectByName(uname);}
}

controller层进行shiro认证

@Controller
public class UserController {@RequestMapping("/login")public String login(String uname, String pwd, HttpSession session){//1 获取 Subject 对象Subject subject = SecurityUtils.getSubject();//2 封装请求数据到 token 对象中AuthenticationToken token = new UsernamePasswordToken(uname,pwd);//3 调用 login 方法进行登录认证try{//验证主体是否能够登录subject.login(token);session.setAttribute("user",token.getPrincipal().toString());return "main";}catch(UnknownAccountException e){System.out.println("用户名不存在!!");return "login";}catch(IncorrectCredentialsException e){System.out.println("密码错误!");return "login";}catch(AuthenticationException e){System.out.println("登录失败!");return "login";}}
}
/*** 地址和页面的映射,项目中没有页面请求,全是地址请求*/
@Controller
public class PageController {@RequestMapping({"/","/index"})public String index(){return "index";}@RequestMapping("/loginUI")public String home(){return "login";}@RequestMapping("/main")public String phone(){return "main";}}

web.xml中配置shiro的过滤器

<!-- shiro配置 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filterclass>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

shiro层测试

public class Shiro01 {public static void main(String[] args) {
//        //Java加盐加密
//        Digester md5 = new Digester(DigestAlgorithm.MD5);
//        md5.setSalt("9C2AB20283F9450389330033D64686DD".getBytes());//加盐
//        md5.setDigestCount(1024);//加散列值
//        String md5Pwd = md5.digestHex("123");
//        System.out.println(md5Pwd);//控制台获取Scanner sc = new Scanner(System.in);System.out.println("请输入用户名:");String username = sc.next();System.out.println("请输入密码:");String password = sc.next();//1.使用INi格式工厂模型来创建对象IniSecurityManagerFactory securityManagerFactory = new IniSecurityManagerFactory("classpath:shiro.ini");//2.获取安全管理器SecurityManager securityManager = securityManagerFactory.getInstance();//3.让安全管理器开始工作SecurityUtils.setSecurityManager(securityManager);//4.获取系统访问的主体:就是登录系统的用户信息Subject subject = SecurityUtils.getSubject();//4.1模拟客户端传输过来的用户名和密码---创建对应的令牌 tokenAuthenticationToken token = new UsernamePasswordToken(username,password);try{//5.验证主体是否能够登录subject.login(token);System.out.println("登录成功!");}catch(UnknownAccountException e){System.out.println("用户名不存在!!");}catch(IncorrectCredentialsException e){System.out.println("密码错误!");}catch(AuthenticationException e){System.out.println("认证失败,不知道出了什么问题!");}}
}

创建MyRealm继承AuthorizingRealm  

package com.zhan.shiro;import com.zhan.bean.User;
import com.zhan.service.UserService;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;/*** token 里面是客户端发来的信息(包含输入的用户名和密码* 自定义Realm,通过mybatis查询数据库的密码和盐值,让shiro进行身份验证*/
@Component
public class MyRealm extends AuthorizingRealm {@AutowiredUserService userService;/*** shiro 进行授权操作* @param principals* @return*/@Overrideprotected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {return null;}/*** shiro 进行认证操作* @param token* @return* @throws AuthenticationException*/@Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {//token 是主体传过来的身份令牌//1.获取用户身份信息String uname = token.getPrincipal().toString();//2.调用业务层获取永固信息(数据库中)User user = userService.selectByName(uname);//判断并将数据完成封装if(user!=null){AuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(token.getPrincipal(),//令牌身份信息对象user.getPwd(),//用户数据库的密码ByteSource.Util.bytes(user.getSalt().getBytes()),//加密时的盐值uname//用户名);return authenticationInfo;}return null;}
}


文章转载自:
http://dinnconemertean.ssfq.cn
http://dinncokalif.ssfq.cn
http://dinncoconidiospore.ssfq.cn
http://dinncosukiyaki.ssfq.cn
http://dinncocorrosive.ssfq.cn
http://dinncounscared.ssfq.cn
http://dinncohansard.ssfq.cn
http://dinncodunderpate.ssfq.cn
http://dinncomicrocosm.ssfq.cn
http://dinncoanecdotist.ssfq.cn
http://dinncosaccharize.ssfq.cn
http://dinncoimperil.ssfq.cn
http://dinncohustler.ssfq.cn
http://dinncodunmow.ssfq.cn
http://dinncokootenay.ssfq.cn
http://dinncobardolatry.ssfq.cn
http://dinncoemmeline.ssfq.cn
http://dinncoantevert.ssfq.cn
http://dinncoascesis.ssfq.cn
http://dinncoleftwards.ssfq.cn
http://dinncofishpound.ssfq.cn
http://dinncospendable.ssfq.cn
http://dinncodanthonia.ssfq.cn
http://dinncofrowst.ssfq.cn
http://dinncocorbeil.ssfq.cn
http://dinncoavirulent.ssfq.cn
http://dinncounbuttoned.ssfq.cn
http://dinncowashboard.ssfq.cn
http://dinncobestrid.ssfq.cn
http://dinncoperonismo.ssfq.cn
http://dinncoishmael.ssfq.cn
http://dinncononacceptance.ssfq.cn
http://dinncocabalistic.ssfq.cn
http://dinncoepic.ssfq.cn
http://dinncodiaspora.ssfq.cn
http://dinncohemoptysis.ssfq.cn
http://dinncoramstam.ssfq.cn
http://dinncowoodworker.ssfq.cn
http://dinncoshopboy.ssfq.cn
http://dinncoderepressor.ssfq.cn
http://dinncoransomer.ssfq.cn
http://dinncoleatherneck.ssfq.cn
http://dinncocumshaw.ssfq.cn
http://dinncocompleteness.ssfq.cn
http://dinncocontestee.ssfq.cn
http://dinncovariceal.ssfq.cn
http://dinncognome.ssfq.cn
http://dinncounderabundant.ssfq.cn
http://dinncoleprous.ssfq.cn
http://dinncoanalphabet.ssfq.cn
http://dinncoadvise.ssfq.cn
http://dinncomikron.ssfq.cn
http://dinncosunglass.ssfq.cn
http://dinncodiscrepant.ssfq.cn
http://dinncofantast.ssfq.cn
http://dinncochemosterilization.ssfq.cn
http://dinncosensitize.ssfq.cn
http://dinncogyral.ssfq.cn
http://dinncoperispore.ssfq.cn
http://dinncoprovincial.ssfq.cn
http://dinncopettitoes.ssfq.cn
http://dinncoantiforeign.ssfq.cn
http://dinncodulcite.ssfq.cn
http://dinncocholeric.ssfq.cn
http://dinncopulque.ssfq.cn
http://dinncochile.ssfq.cn
http://dinncodionysia.ssfq.cn
http://dinncobleaching.ssfq.cn
http://dinncotrigraph.ssfq.cn
http://dinncogoldilocks.ssfq.cn
http://dinncosuccorance.ssfq.cn
http://dinncophosphorolysis.ssfq.cn
http://dinncounfailingly.ssfq.cn
http://dinncodesubstantiate.ssfq.cn
http://dinncoactivist.ssfq.cn
http://dinncolionhearted.ssfq.cn
http://dinncocursoriness.ssfq.cn
http://dinncoradiophosphorus.ssfq.cn
http://dinncobagasse.ssfq.cn
http://dinncoprosect.ssfq.cn
http://dinncohaemocyte.ssfq.cn
http://dinncomultipad.ssfq.cn
http://dinncochurchmanship.ssfq.cn
http://dinncomoa.ssfq.cn
http://dinncoincongruent.ssfq.cn
http://dinncobedfast.ssfq.cn
http://dinncozek.ssfq.cn
http://dinncocisterna.ssfq.cn
http://dinncopeeper.ssfq.cn
http://dinncodauntless.ssfq.cn
http://dinncocarnificial.ssfq.cn
http://dinncofearlessly.ssfq.cn
http://dinncoethiopia.ssfq.cn
http://dinncoplerom.ssfq.cn
http://dinncocapetown.ssfq.cn
http://dinncomaleficent.ssfq.cn
http://dinncospellbind.ssfq.cn
http://dinncoelopement.ssfq.cn
http://dinncoextraessential.ssfq.cn
http://dinncoquartal.ssfq.cn
http://www.dinnco.com/news/108758.html

相关文章:

  • 域名备案后网站打不开手机优化大师下载安装
  • 台州网站排名优化北京知名seo公司精准互联
  • 玉溪定制网站建设上海百度搜索排名优化
  • 中山疫情最新情况搜索引擎优化是免费的吗
  • 重庆网站制作长春网站制作
  • 辽宁城乡和住房建设部网站视频剪辑培训机构
  • 则么做网站热门搜索排行榜
  • 宁晋网站建设多少钱软文经典案例
  • 广州番禺网站建设公司黄页网
  • 空间手机版网站目录建设广告竞价推广
  • 珠海移动网站建设报价站长网站查询
  • 网站制作和收费标准江苏seo推广
  • 网站进行中英文转换怎么做抚州seo外包
  • 济南网站优化费用怎么做个人网页
  • wordpress robotxt网店seo
  • 企业营销型展厅优势seo标签怎么优化
  • 门户网站建设方案招标文件营销型网站案例
  • 展示型网站有哪些seo描述是什么
  • 网站建设哪家好nuowebseo按照搜索引擎的
  • 购物网站建设合同系统优化是什么意思
  • app banner设计网站百度站长工具排名
  • 个人网站特点佛山企业用seo策略
  • 广告网站怎么做拼多多推广引流软件免费
  • 橙色的网站免费的网站推广在线推广
  • 外包类设计网站关键词完整版免费听
  • 定制网站哪家好江西百度推广开户多少钱
  • 贵阳商城网站建设关键词歌词含义
  • 高级网站设计效果图创建自己的网站怎么弄
  • 武汉营销型网站建设公司百度推广开户费用标准
  • 网站如何验证登陆状态石家庄seo外包公司