日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Springsecurity之AuthenticationEntryPoint

發布時間:2025/5/22 javascript 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Springsecurity之AuthenticationEntryPoint 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

? ? 注意:分析的版本是Springsecurity的4.3.x。

? ? 在ExceptionTranslationFilter中使用到AuthenticationEntryPoint,當ExceptionTranslationFilter截獲AuthenticationException

或者AccessDeniedException異常時,就會調用AuthenticationEntryPoint的commence。AuthenticationEntryPoint有很多實現類,我們來看下CasAuthenticationEntryPoint,這個與單點登錄有關。先上一張圖,如下圖1所示。

??

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 圖1?CasAuthenticationEntryPoint的繼承圖

? ? 如果查看Springsecurity的cas那部分的文檔,會看到如下List-1所示的內容,

? ? List-1

<bean id="casEntryPoint"class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"><property name="loginUrl" value="https://localhost:9443/cas/login"/><property name="serviceProperties" ref="serviceProperties"/> </bean><bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"><property name="service" value="https://localhost:8443/cas-sample/login/cas"/><property name="sendRenew" value="false"/> </bean>

????CasAuthenticationEntryPoint的commence方法中,如下List-2所示,方法createServiceUrl和createRedirectUrl是構建調用CAS server的url,方法preCommence是空方法體,最后設置respose的redirect地址,這樣瀏覽器收到的是302狀態碼,然后瀏覽器訪問List-2中的redirectUrl,redirectUrl的值是"https://localhost:9443/cas/login?service=https://localhost:8443/cas-sample/login/cas"。

? ? List-2?

public final void commence(final HttpServletRequest servletRequest, final HttpServletResponse response,final AuthenticationException authenticationException) throws IOException,ServletException {final String urlEncodedService = createServiceUrl(servletRequest, response);final String redirectUrl = createRedirectUrl(urlEncodedService);preCommence(servletRequest, response);response.sendRedirect(redirectUrl);}

? ? 注:List-2中的createServiceUrl和createRedirectUrl在構造Http請求鏈接的時候,有點復雜,這里就不再細講。

轉載于:https://my.oschina.net/u/2518341/blog/2874750

總結

以上是生活随笔為你收集整理的Springsecurity之AuthenticationEntryPoint的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。