zoukankan      html  css  js  c++  java
  • shiro设置加密算法源码解析

    本文首次发布于My Blog,作者Ian,转载请保留原文链接。

    自定义Realm继承AuthorizingRealm父类。
    HashedCredentialsMatcher 实例化并设置加密算法。

    源码:

       public AuthorizingRealm(CredentialsMatcher matcher) {
            this((CacheManager)null, matcher);
        }
    
    设置迭代次数:
       public void setHashIterations(int hashIterations) {
            if (hashIterations < 1) {
                this.hashIterations = 1;
            } else {
                this.hashIterations = hashIterations;
            }
        }
    

    最后把实例化HashedCredentialsMatcher对象通过父类构造方法设置。

    源码:

        public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) {
            this.credentialsMatcher = credentialsMatcher;
        }
    
        public interface CredentialsMatcher {
            boolean doCredentialsMatch(AuthenticationToken var1, AuthenticationInfo var2);
        }
        HashedCredentialsMatcher实现CredentialsMatcher接口
    

    源码:

        public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
            Object tokenHashedCredentials = this.hashProvidedCredentials(token, info);
            Object accountCredentials = this.getCredentials(info);
            return this.equals(tokenHashedCredentials, accountCredentials);
        }
    
  • 相关阅读:
    Unity-JobSystem
    Unity-ECS-实践
    Unity-Editor
    网络编程-HTTPS
    网络编程-UDP、TCP
    Cast, OfType
    DataGrid
    bat 开机自动执行脚本
    bat 单行输出彩色信息
    工厂模式
  • 原文地址:https://www.cnblogs.com/uniquezhangqi/p/9199469.html
Copyright © 2011-2022 走看看