Java源碼分析系列之HttpServletRequest源碼分析

來源:互聯網
上載者:User

標籤:ram   ext   策略   java源碼   xtend   span   tps   dia   ges   

 從源碼當中 我們可以 得知,HttpServletRequest其實 實際上 並 不是一個類,它只是一個標準,一個 介面而已,它的 父類是ServletRequest。

認證方式
public interface HttpServletRequest extends ServletRequest 

  從閱讀源碼 當中 ,我們 可以 獲得 如下認證資訊:

    /**    * String identifier for Basic authentication. Value "BASIC"    */    public static final String BASIC_AUTH = "BASIC";    /**    * String identifier for Form authentication. Value "FORM"    */    public static final String FORM_AUTH = "FORM";    /**    * String identifier for Client Certificate authentication. Value "CLIENT_CERT"    */    public static final String CLIENT_CERT_AUTH = "CLIENT_CERT";    /**    * String identifier for Digest authentication. Value "DIGEST"    */    public static final String DIGEST_AUTH = "DIGEST";

  分別是 BASIC,FORM,CLIENT_CERT,DIGEST,那麼 這幾種不同的認證有什麼區別呢?

  下面 是一些 介紹 :

  Basic:這種 情況下 ,需要 使用者名稱和密碼 進行認證,用使用者 輸入的使用者名稱 和密碼 和 伺服器上 的資料 中 的目前使用者的使用者名稱和 密碼 進行對比 。具體的流程如所示 :

  1. 用戶端請求伺服器的受保護的資源
  2. 伺服器發一個 請求,去 用戶端 請求 username和password.
  3. 用戶端 發送 使用者名稱 和密碼給服務端
  4. 服務端返回相應的資料給 用戶端 

 

  這種 認證 方式並不是安全的,用戶端發送的使用者名稱 和密碼 是 Base64形式 加密的文本,這種情況的 使用者名稱和 密碼 是會被暴露 出來的,如果 有 人能夠截獲使用者名稱和密碼 ,這是 很 容易被解碼的,當然 如果 使用 的是 SSL,HTTPS等 策略的話,會減少這種風險的發生率。

參考資料
  • https://docs.oracle.com/cd/E19575-01/819-3669/bncbn/index.html

Java源碼分析系列之HttpServletRequest源碼分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.