-
shiro查看全部
-
1 創(chuàng)建SecurityManager 環(huán)境
2 主體提交(Subject)認(rèn)證
3 通過(guò)SecurityManager認(rèn)證
4 通過(guò)Authenticator 認(rèn)證
5 通過(guò)Realm 認(rèn)證
查看全部 -
查看全部
-
控制角色權(quán)限的注解,requirePermissions可以寫入多個(gè)角色權(quán)限,推薦使用
查看全部 -
加鹽
查看全部 -
MD5加密
查看全部 -
查看全部
-
中間
查看全部 -
開(kāi)始?
查看全部 -
項(xiàng)目結(jié)構(gòu)圖
查看全部 -
springmvc.xml的配置
<?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
? ? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? ? xmlns:context="http://www.springframework.org/schema/context"
? ? ? xmlns:mvc="http://www.springframework.org/schema/mvc"
? ? ? xsi:schemaLocation="http://www.springframework.org/schema/beans
? ?http://www.springframework.org/schema/beans/spring-beans.xsd
? ?http://www.springframework.org/schema/context
? ?http://www.springframework.org/schema/context/spring-context.xsd
? ?http://www.springframework.org/schema/mvc
? ?http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
? ? ? ?<context:component-scan base-package="com.imooc.controller"/>
? ? ? ?<mvc:annotation-driven/>
? ? ? ?<!--排除靜態(tài)文件-->
? ? ? ?<mvc:resources mapping="/*" location="/"/>
</beans>查看全部 -
spring.xml的配置
<?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
? ? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? ? xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
? ?<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
? ? ? ?<property name="securityManager" ref="securityManager"/>
? ? ? ?<property name="loginUrl" value="login.html"/>
? ? ? ?<property name="unauthorizedUrl" value="403.html"/>
? ? ? ?<property name="filterChainDefinitions">
? ? ? ? ? ?<value>
? ? ? ? ? ? ? ?/login.html = anon
? ? ? ? ? ? ? ?/subLogin = anon
? ? ? ? ? ? ? ?/* = authc
? ? ? ? ? ?</value>
? ? ? ?</property>
? ?</bean>
? ?<!--創(chuàng)建SecurityMananger對(duì)象-->
? ?<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
? ? ? ?<!--設(shè)置自定義Realm-->
? ? ? ?<property name="realm" ref="realm"/>
? ?</bean>
? ?<!--定義自定義的Realm-->
? ?<bean id="realm" class="com.imooc.shiro.realm.CustomerRealm">
? ? ? ?<property name="credentialsMatcher" ref="credentialsMatcher"/>
? ?</bean>
? ?<!--設(shè)置加密的算法-->
? ?<bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"
? ? ? ? ?id="credentialsMatcher">
? ? ? ?<property name="hashAlgorithmName" value="md5"/>
? ? ? ?<property name="hashIterations" value="1"/>
? ?</bean>
</beans>查看全部 -
web.xml的配置
<?xml?version="1.0"?encoding="UTF-8"?> <web-app?xmlns="http://xmlns.jcp.org/xml/ns/javaee" ?????????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ?????????xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee?http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" ?????????version="3.1"> ????<filter> ????????<filter-name>shiroFilter</filter-name> ????????<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> ????</filter> ????<filter-mapping> ????????<filter-name>shiroFilter</filter-name> ????????<url-pattern>/*</url-pattern> ????</filter-mapping> ????<context-param> ????????<param-name>contextConfigLocation</param-name> ????????<param-value>classpath:spring/spring.xml</param-value> ????</context-param> ????<listener> ????????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> ????</listener> ????<servlet> ????????<servlet-name>DispatcherServlet</servlet-name> ????????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> ????????<init-param> ????????????<param-name>contextConfigLocation</param-name> ????????????<param-value>classpath:spring/springmvc.xml</param-value> ????????</init-param> ????????<load-on-startup>1</load-on-startup> ????????<async-supported>true</async-supported> ????</servlet> ????<servlet-mapping> ????????<servlet-name>DispatcherServlet</servlet-name> ????????<url-pattern>/</url-pattern> ????</servlet-mapping> ????<!--?注冊(cè)spring提供的針對(duì)POST請(qǐng)求的中文亂碼問(wèn)題?--> ????<filter> ????????<filter-name>CharacterEncodingFilter</filter-name> ????????<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> ????????<init-param> ????????????<param-name>encoding</param-name> ????????????<param-value>UTF-8</param-value> ????????</init-param> ????</filter> ????<filter-mapping> ????????<filter-name>CharacterEncodingFilter</filter-name> ????????<url-pattern>/*</url-pattern> ????</filter-mapping> </web-app>
查看全部 -
MD5加密,加鹽。
查看全部 -
Shiro加密
查看全部
舉報(bào)
0/150
提交
取消