Shiro(四)授權 角色認證

2021-10-23 10:47:56 字數 1051 閱讀 2994

1、shiroconfig

@configuration

public

class

shiroconfig/*

** 建立defaultwebsecuritymanager安全管理器

*/@bean

(name =

"defaultwebsecuritymanager"

)public defaultwebsecuritymanager getdefaultwebsecuritymanager

(@qualifier

("userrealm"

) userrealm userrealm)

/** * 建立realm

*/@bean

(name =

"userrealm"

)public userrealm getreaml()

}

多realm三種情況

2、userrealm

//繼承authorizingrealm

public

class

userrealm

extends

authorizingrealm

/** * 執行認證邏輯

*/@override

protected authenticationinfo dogetauthenticationinfo

(authenticationtoken authenticationtoken)

throws authenticationexception

//2、自動判斷密碼,第1個為principal,第二位密碼,第三為shiro名字

return

new******authenticationinfo

(user,user.

getpassword()

,getname()

);}}

多realm只要乙個通過即可

shiro認證授權

1.shiro配置類 1.1需要配置什麼?建立乙個shirofilte ctorybean物件,檢測認證 向bean中傳入securitymanager物件 沒有認證的時候應該訪問哪個url位址 setloginurl 哪些資源是可以被匿名訪問的 setfilterchaindefinitionma...

shiro 實現認證授權

一.認證和授權的概念 認證 authentication show it,you are you 授權 authoriziation through it,you can do sth 二.shiro中的認證與授權 authenticatingrealm shiro中的用於進行認證的領域,實現dog...

shiro認證授權過程

nclick formsubmit login.action self public string login throws exception subject.login token 當這一 執行時,就會自動跳入到authrealm中認證方法 protected authenticationinf...