Shrio的登录验证过程中的密码验证,过程,及relam在applicationContext.xml的配置
private String hashAlgorithm; //加密耍法
private int hashIterations; //加密次数
private boolean hashSalted; //盐值加密
private boolean storedCredentialsHexEncoded;
输入密码提交后,后台获取提交的密码与数据中的密码进行比对,在比对前会先进行加密:
调取加密参数,对对象进行加密
使用Reaml实现类的方式配置SecurityManager:
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="cacheManager" ref="cacheManager"/> <!-- Single realm app. If you have multiple realms, use the 'realms' property instead. --> <!-- <property name="sessionMode" value="native"/> --> <!-- Realm,实现类 --> <property name="realm" ref="jdbcRealm"/> </bean>
<bean id="jdbcRealm" class="com.shiro.bean.ShiroRealm"> <!-- 配置密码加密使用MD5加密 --> <property name="CredentialsMatcher"> <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"> <property name="hashAlgorithmName" value="MD5"></property> <property name="hashIterations" value="1024"></property> </bean> </property> </bean>