CAS overlay template 4.2.7 獲取除使用者名稱外其他資訊遇到的問題
阿新 • • 發佈:2019-01-25
CAS服務端配置了mysql 使用者名稱密碼驗證,去掉了https校驗。
客戶端端通過配置web.xml相關filter。其中注意,我配置了
Cas20ProxyReceivingTicketValidationFilter
客戶端是通過
cas-client-core-3.4.1.jar!CommonUtils的
getResponseFromServer(URL constructedUrl, HttpURLConnectionFactory factory, String encoding)
方法獲取服務端返回的流資訊,但是問題是始終返回不了其他使用者屬性資訊。
我也是抱著試一試的態度,把
Cas20ProxyReceivingTicketValidationFilter
換成了
Cas30ProxyReceivingTicketValidationFilter
,測試成功,返回了相關使用者資訊。
這裡記錄一下,目前
Cas20ProxyReceivingTicketValidationFilter為什麼沒有獲取到額外使用者資訊,沒有找到原因。先用著,沒有時間去一行行找問題了。
後面看原始碼發現,
protected void prepareMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { super.prepareMergedOutputModel(model, request, response); Service service = super.getServiceFrom(model); RegisteredService registeredService = this.servicesManager.findServiceBy(service); Map<String, Object> attributes = new HashMap(this.getPrincipalAttributesAsMultiValuedAttributes(model)); attributes.put("authenticationDate", Collections.singleton(this.getAuthenticationDate(model))); attributes.put("isFromNewLogin", Collections.singleton(Boolean.valueOf(this.isAssertionBackedByNewLogin(model)))); attributes.put("longTermAuthenticationRequestTokenUsed", Collections.singleton(Boolean.valueOf(this.isRememberMeAuthentication(model)))); this.decideIfCredentialPasswordShouldBeReleasedAsAttribute(attributes, model, registeredService); this.decideIfProxyGrantingTicketShouldBeReleasedAsAttribute(attributes, model, registeredService); super.putIntoModel(model, "attributes", this.casAttributeEncoder.encodeAttributes(attributes, this.getServiceFrom(model))); }
大概問題就在這裡了。