Shiro添加凭证匹配器(加密器)(十五)

1.spring-shiro配置文件中配置加密器

    <!--加密器-->
	<bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
		<!--加密算法-->
		<property name="hashAlgorithmName" value="md5" />
		<!--散列次数-->
		<property name="hashIterations" value="3" />
	</bean>

2.自定义realm引用加密器

<!--配置自定义的realm-->
	<bean id="userRealm" class="cn.wolfcode.shiro.realm.UserRealm">
		<!--密码需要加密:加密器-->
		<property name="credentialsMatcher" ref="credentialsMatcher" />
	</bean>

3.修改UserRealm中的认证操作, 添加加密的盐

猜你喜欢

转载自blog.csdn.net/qq_37431224/article/details/103970210
今日推荐