shiro 用户登录 md5 配置

馋奶兔 提交于 2020-08-10 08:00:59

一般的用户登录密码都是MD5加密的了,算是标配吧。本文说的是自定义一个ShiroDbRealm,然后把shiro自带的HashedCredentialsMatcher给set进去。

当然你可以自己扩展。

<bean id="shiroDbRealm" class="xxx.ShiroDbRealm">
        <constructor-arg index="0" name="cacheManager" ref="shiroJedisCacheManager"/>

        <!-- 启方式1 -->
        <!-- <constructor-arg index="1" name="matcher" ref="credentialsMatcher"/>-->
        <!-- 启用身份验证缓存,即缓存AuthenticationInfo信息,默认false -->
        <property name="authenticationCachingEnabled" value="false"/>
        <!-- 缓存AuthenticationInfo信息的缓存名称 -->
        <property name="authenticationCacheName" value="authenticationCache"/>
        <!-- 缓存AuthorizationInfo信息的缓存名称 -->
        <property name="authorizationCacheName" value="authorizationCache"/>

        <!-- 启方式1 -->
        <property name="credentialsMatcher" ref="credentialsMatcher"/>
            
        </property>
    </bean>
    
    <bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
                <constructor-arg index="0" value="md5"/>
                <!-- 迭代次数默认1 -->
                <property name="hashIterations" value="1"/>
    </bean>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!