security安全包應(yīng)該是identity身份模塊中很重要的組成部分,其中主要包含以下類:
一、AuthenticatedUser認(rèn)證用戶類:其中很簡(jiǎn)單,就是gettter和setter 方法,設(shè)置和獲取authenticatedUser。
其中的authenticatedUser是一個(gè)ThreadLocal。
二、IdentityLoginModule身份登陸模塊類:
實(shí)現(xiàn)LoginModule接口。這個(gè)類和javax.security.auth.*等包結(jié)合非常緊密。
三、IdentityPolicy身份政策類:擴(kuò)展Policy類。
四、IdentityService身份服務(wù)接口:驗(yàn)證用戶和獲取User
五、Password和Usename JavaBean
------------------------------------------------------------
補(bǔ)充知識(shí):
1.ThreadLocal
This class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID).
這支持支持thread-local 變量。這些變量不同于它們常用的對(duì)應(yīng)物,在那每一個(gè)線程獲得一個(gè)(依靠get或set方法)擁有它自己的,獨(dú)立地初始化復(fù)制這個(gè)變量。ThreadLocal實(shí)例是典型地私有靜態(tài)字段,它希望聯(lián)系狀態(tài)使用線程(例如;一個(gè)用戶ID或事務(wù)ID)。