我阅读了这篇文章CAS SSO With Spring Security并成功运行了源代码,但是这个客户端只获取用户名,我希望我的客户端需要来自 CAS 服务器的更多字段。
在我以前使用传统 SpringMVC 的 CAS 客户端中,我可以获取所有文件,包括用户名、电话号码、密码和电子邮件。主要步骤如下: 在 CAS 服务器的文件 WEB-INF/classes/services/Apereo-10000002.json 中,我添加了一个选项:
"attributeReleasePolicy" : {
"@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
}
在客户端,我使用getUserPrincipal
如下
@RequestMapping("/cas/login.do")
@ResponseBody
public String casLogin(String uri,
HttpServletRequest request,...){
...
Principal principal = request.getUserPrincipal();
Map<String,Object> userInfo = new HashMap<>();
if (p instanceof AttributePrincipal) {
userInfo =( (AttributePrincipal)principal).getAttributes();
}
System.err.println("image:"+userInfo.get("image"));
System.err.println("username:"+userInfo.get("username"));
System.err.println("email:"+userInfo.get("email"));
System.err.println("phoneNo:"+userInfo.get("phoneNo"));
...
}
现在我想根据spring boot + spring security
上述文章实现一个 CAS 客户端。但是根据文章代码,我该怎么办?提前致谢!