securityManager設(shè)置realm之后,realm再設(shè)置matcher,怎么生效的?
CustomRealm?customRealm?=?new?CustomRealm(); DefaultSecurityManager?defaultSecurityManager?=?new?DefaultSecurityManager(); //?設(shè)置realm defaultSecurityManager.setRealm(customRealm); HashedCredentialsMatcher?matcher?=?new?HashedCredentialsMatcher(); matcher.setHashAlgorithmName("md5"); matcher.setHashIterations(1); //?設(shè)置matcher customRealm.setCredentialsMatcher(matcher); SecurityUtils.setSecurityManager(defaultSecurityManager);
2018-12-19
JAVA的對(duì)象參數(shù)是引用傳遞的而不是值傳遞。你無(wú)論什么時(shí)候設(shè)置對(duì)象參數(shù)的屬性都一樣。
2018-09-03
去看HashedCredentialsMatcher的源碼,里邊有個(gè)doCredentialsMatch方法,你可以把斷點(diǎn)打到這里,程序運(yùn)行的時(shí)候一步步看,很清楚地就能看到shiro的匹配過(guò)程
2018-07-02
java的引用傳遞
2018-05-22
matcher設(shè)置進(jìn)到了customRealm,customRealm設(shè)置進(jìn)了defaultSecurityManager,
defaultSecurityManager設(shè)置進(jìn)到了SecurityUtils,
通過(guò)SecurityUtils獲取一個(gè)subject主體,登錄的token會(huì)依據(jù)這條鏈路最終使用到設(shè)置的匹配器matcher的規(guī)則去進(jìn)行權(quán)限認(rèn)證。