cas服务端后续

本文介绍了CAS服务端配置的SafeDispatcherServlet,该Servlet用于转发请求到webflow进行处理。解析了其工作原理,包括初始化过程和服务请求的具体实现,并说明了在web.xml中的配置方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

public final class SafeDispatcherServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public static final String CAUGHT_THROWABLE_KEY = "exceptionCaughtByServlet";
    private static final Logger LOGGER = LoggerFactory.getLogger(SafeDispatcherServlet.class);
    private DispatcherServlet delegate = new DispatcherServlet();
    private boolean initSuccess = true;

    public SafeDispatcherServlet() {
    }

    public void init(ServletConfig config) {
        try {
            this.delegate.init(config);
        } catch (Throwable var5) {
            this.initSuccess = false;
            String message = "SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized.";
            LOGGER.error("SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized.", var5);
            ServletContext context = config.getServletContext();
            context.log("SafeDispatcherServlet: \nThe Spring DispatcherServlet we wrap threw on init.\nBut for our having caught this error, the servlet would not have initialized.", var5);
            context.setAttribute("exceptionCaughtByServlet", var5);
        }

    }

    public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
        if (this.initSuccess) {
            this.delegate.service(req, resp);
        } else {
            throw new ApplicationContextException("Unable to initialize application context.");
        }
    }
}

cas服务端配置的servlet,

org.jasig.cas.web.init.SafeDispatcherServlet 这个Servlet主要是进行转发,将接收到的请求转交给webflow来处理。   

它实际上是spring-webflow的应用

有关spring-webflow的详细介绍,

网上铺天盖地,我就不啰嗦了

cas server端的web.xml文件里面有

 <servlet>
  <servlet-name>cas</servlet-name>
  <servlet-class>
   org.jasig.cas.web.init.SafeDispatcherServlet
  </servlet-class>
  <init-param>
   <param-name>publishContext</param-name>
   <param-value>false</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

这个是login-webflow的入口servlet,映射的url-pattern之一就是

<servlet-mapping>
  <servlet-name>cas</servlet-name>
  <url-pattern>/login</url-pattern>
 </servlet-mapping>

即login

spring webflow必须在flow-registry里面注册,

这个是在cas-servlet.xml里面注册的

<webflow:flow-registry id="flowRegistry" flow-builder-services="builder">
        <webflow:flow-location path="/WEB-INF/login-webflow.xml" id="login" />
    </webflow:flow-registry>

对应的view properties在propertyFileConfigurer.xml中指定了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值