# Java 的認證、授權服務
###### tags: `java` `jaas` `authorization` `authentication` `library` `security`
Java Authentication and Authorization Service <sub>簡稱 JAAS</sub>,為一個補足早期的 Java 缺少以用戶為中心的安全框架;剛開始是由 Sun Microsystems 以函式庫的形式提供,後來整合到 1.4<sub>(及後來版本)</sub>的 JDK/JRE 裡。對 application developer(s)來說它提供了:
* > Representation of identity (**Principal**) and a set of credentials (**Subject**).
* Principal
代表了某人名、團體名、帳號名稱、身分證字號或社會安全號碼等等之類的唯一識別**身份**。
* Subject
代表一系列**憑證**。
* > **Login service** that will invoke your application callbacks to ask the user things like username and password. It returns a new **Subject**.
* login service
向 client user 索取諸如**帳號**、**密碼**等資訊並回傳一個 Subject。
* > **Authorization service** that tests if a **Subject** was granted a permission by an administrator.
* authorization service
驗證某個 Subject 是否真有被授權。
## 參考來源
* [維基百科](https://zh.wikipedia.org/wiki/JAAS)
* [Wikipedia](https://en.wikipedia.org/wiki/Java_Authentication_and_Authorization_Service)
* [Reference Guide](https://docs.oracle.com/javase/8/docs/technotes/guides/security/jaas/JAASRefGuide.html "官方的參考指南")
## 相關筆記
* [淺談 Java 的 principal](https://hackmd.io/@pclin/r1xCI-WXU)