CAS Server 4.0二次开发说明文档(4)

2019-05-17 09:49

count++; context.getFlowScope().put(\ return handlerError.getSimpleName(); } } } } final String messageCode = this.messageBundlePrefix + UNKNOWN; logger.trace(\by default...\messageContext.addMessage(new MessageBuilder().error().code(messageCode).build()); count++; context.getFlowScope().put(\return UNKNOWN; } 5.7. 修改配置cas-servlet.xml

修改src\\main\\webapp\\WEB-INF\\cas-servlet.xml

CaptchaVaditeAuthenticationViaFormAction

5.8. 修改配置login-webflow.xml

修改src\\main\\webapp\\WEB-INF\\login-webflow.xml文件,该文件采用了spring-web-flow.在这里定义描述了整个cas server的登录校验认证流程。接下来,需要在登录属性表单中添加验证码字段及添加修改有关涉及到验证码校验的流程

替换原来的credential配置为UsernamePasswordCaptchaCredential

..... 6. CAS服务器端返回多个属性字段

通常情况下,cas server认证成功后返回的属性字段很少,但在很多场合下登录后需要获取到许多字段属性。这时候我们就需要个性化来定制cas server返回的字段属性了。这里为了方便演示期间,创建了一个MultipleAttributeUserDao类,并重写了IPersonAttributes方法,在这里模拟了一些字段属性。在生产环境时,可将该部分代码替换,根据业务需求换成从数据库中查询的业务逻辑代码。

6.1. 创建MultipleAttributeUserDao模拟用户自定义属性

package org.jasig.services.persondir.support; import org.jasig.services.persondir.IPersonAttributes; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 扩展用户自定义属性 * Created by Administrator on 2016/4/30 0030. */ public class MultipleAttributeUserDao extends StubPersonAttributeDao { @Override public IPersonAttributes getPerson(String uid) { Map> attributes = new HashMap>(); attributes.put(\ attributes.put(\测试username\ attributes.put(\ return new AttributeNamedPersonImpl(attributes); } } 6.2. 修改deployerConfigContext.xml

修改src\\main\\webapp\\WEB-INF\\deployerConfigContext.xml文件,添加配置我们自定义的MultipleAttributeUserDao

6.3. 修改casServiceValidationSuccess.jsp

至此为了能获取到我们的自定义属性还不需要修改src\\main\\webapp\\WEB-INF\\view\\jsp\\protocol\\2.0\\casServiceValidationSuccess.jsp和src\\main\\webapp\\WEB-INF\\view\\jsp\\protocol\\3.0\\casServiceValidationSuccess.jsp文件。添加获取用户自定义属性的代码块。

src\\main\\webapp\\WEB-INF\\view\\jsp\\protocol\\2.0\\casServiceValidationSuccess.jsp <%-- <%@ page session=\<%@ taglib prefix=\<%@ taglib uri=\ ${fn:escapeXml(assertion.primaryAuthentication.principal.id)} 0}\ ${fn:escapeXml(attr.value)} ${pgtIou} ${fn:escapeXml(proxy.principal.id)} src\\main\\webapp\\WEB-INF\\view\\jsp\\protocol\\3.0\\casServiceValidationSuccess.jsp <%@ page session=\<%@ page import=\<%@ taglib prefix=\<%@ taglib uri=\ ${fn:escapeXml(assertion.primaryAuthentication.principal.id)} ${pgtIou} ${fn:escapeXml(proxy.principal.id)} <% Entry entry = (Entry) pageContext.getAttribute(\ Object value = entry.getValue(); pageContext.setAttribute(\ %> <%-- it's a String, output it once --%> ${fn:escapeXml(attr.value)} <%-- if attribute is multi-valued, list each value under the same attribute name --%> ${fn:escapeXml(attrval)} 7. CAS Server集群部署时Ticket同步

当cas server被正式用在生产环境时,她需要支撑各个应用系统的登录服务。而cas server只进行一处部署时,这里就存在一个单点故障的问题。一旦出现该问题,就会导致各个应用系统无法正常登录。次问题是极为严重的。因此我们在线上使用的时候就需要将cas server进行集群部署,可cas server相对于其他web应用集群部署有所不同。我们知道cas server的用户身份校验是基于cas ticket的。Cas默认的ticket管理策略是不具备集群部署时ticket同步的。这里就需要我们自行拓展,以达到集群部署时ticket也能同步。

7.1. 添加redis依赖

在这里我们使用redis缓存策略来同步管理cas ticket。因此需要添加redis依赖 org.springframework.data spring-data-redis 1.7.1.RELEASE * * org.apache.commons


CAS Server 4.0二次开发说明文档(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:国家安全网上法律知识竞赛参考答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: