再回頭閱讀Spring-Security3的文件,它提供一個獨立於其它Context之外(包括HTTP的Session)的運作環境:SecurityContextHolder,所以透過j_spring_security_check登入的資訊需從此處取得,可以在Action、Custom Tag或一般Java Class取得,如下:
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
偷窺登入者ID、Password過程有點麻煩,這也可知UserDetails是怎麼來的。
全站熱搜