• CAS学习笔记(二)—— cas server端的login-webflow详细流程


    一、配置文件介绍

    关于spring的配置信息只需放入WEB-INF/spring-configuration目录即可,cas启动时会自动加载。这个目录下的spring配置文件几乎不需要改动。

    在web.xml中配置

    在WEB-INF/spring-configuration中

    1./WEB-INF/spring-configuration/applicationContext.xml
    这个配置文件是cas的核心类配置,你不需要改动。

    2./WEB-INF/spring-configuration/argumentExtractorsConfiguration.xml
    这个配置文件主要是cas参数的提取。比如从应用端重定向到cas 服务器的url地址中的service参数,为什么cas认识,service起什么作用,换一参数名,是否可以?就是这里配置的类来处理的。但是这个你也不需要改动,cas默认是支持cas1.0,cas2.0及saml协议的。

    3./WEB-INF/spring-configuration/propertyFileConfigurer.xml
    加载cas.properties文件。

    4./WEB-INF/spring-configuration/securityContext.xml
    关于安全上下文配置,比如登出,认证等,一般情况下不需要改动它

    5./WEB-INF/spring-configuration/ticketExpirationPolicies.xml
    从文件名就可以知道,它是关于ticket的过期策略配置的,包括ST,TGT.

    6./WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml
    关于cookie的生成

    7./WEB-INF/spring-configuration/ticketRegistry.xml
    ticket的存储

    8./WEB-INF/spring-configuration/uniqueIdGenerators.xml
    ticket Id生成器

    在WEB-INF/中

    1./WEB-INF/cas-servlet.xml
    spring mvc的启动类配置

    2./WebContent/WEB-INF/deployerConfigContext.xml
    cas的认证管理器,认证管理都在这个文件里,可以说进行cas开发,你需要更改的文件中,这是第一个。

    3./WEB-INF/login-webflow.xml
    spring web flow的流程配置文件。读懂了这个文件就可以了解cas的登录流程。

    4./WEB-INF/restlet-servlet.xml
    关于cas 的restlet对外接口服务的.

    二、login-webflow配置信息

    1、web.xml中,login-webflow的入口,如下/login,/remoteLogin

    2、cas-servlet.xml中,在flow-registry里面注册webflow

     3、cas-servlet.xml中,配置主题信息,可以定位到对应的css、js、jsp路径

      上图,在cas.properties中,找到cas.viewResolver.basename

      通过配置文件知道页面信息配置在default_views.properties文件中

    三、web-flow.xml流程介绍

    3.1基本介绍

      1、on-start(start-state)流程开始,end-state流程结束 decision-state判断,类似于if,view-state对应jsp页面 action-state对应执行程序的某段

      2、<evaluate expression="initialFlowSetupAction" />这些定义在cas-servlet.xml中

      3、view-state里面的view定义在default_views.properties中

    3.2实例说明

    <evaluate expression="initialFlowSetupAction" />

    这句话的意思是执行

    org.jasig.cas.web.flow.InitialFlowSetupAction中的doExecute方法

    其中的变量都由spring注入了

    具体看对应的配置文件

    然后下一个流程是

    <decision-state id="ticketGrantingTicketExistsCheck">
      <if test="flowScope.ticketGrantingTicketId neq null" then="hasServiceCheck" else="gatewayRequestCheck" />
     </decision-state>

    进行判断

    flowScope.ticketGrantingTicketId

    这个在org.jasig.cas.web.flow.InitialFlowSetupAction中由

    context.getFlowScope().put(
                "ticketGrantingTicketId", this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));

    这句话放入了,然后在这儿进行检测neq null是不为null的意思

    then else都很好理解

    view state

    复制代码
    <view-state id="viewLoginForm" view="casLoginView" model="credentials">
            <var name="credentials" class="org.jasig.cas.authentication.principal.UsernamePasswordCredentials" />
            <binder>
                <binding property="username" />
                <binding property="password" />
            </binder>
            <on-entry>
                <set name="viewScope.commandName" value="'credentials'" />
            </on-entry>
      <transition on="submit" bind="true" validate="true" to="realSubmit">
                <set name="flowScope.credentials" value="credentials" />
                <evaluate expression="authenticationViaFormAction.doBind(flowRequestContext, flowScope.credentials)" />
            </transition>
     </view-state>
    复制代码

    对应的是casLoginView.jsp

    在这里对一些页面变量和对应的java类进行了绑定

    action state

    复制代码
    <action-state id="realSubmit">
            <evaluate expression="authenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext)" />
      <transition on="warn" to="warn" />
      <transition on="success" to="sendTicketGrantingTicket" />
      <transition on="error" to="viewLoginForm" />
     </action-state>
    复制代码

    执行对应的方法,这儿执行org.jasig.cas.web.flow.AuthenticationViaFormAction中的

    submit方法,并根据返回值到不同的分支

  • 相关阅读:
    超微主板不识别M2-解决方案
    Centos7安装zookpeer
    PowerBI主题制作
    [python错误]UnicodeDecodeError: 'gbk' codec can't decode byte...
    使用Python批量合并PDF文件(带书签功能)
    Oracle使用超大SQL脚本文件恢复数据问题记录
    Linux Mint 18.2安装后需要进行的设置
    Excel使用SUMIF函数注意事项
    CSV文件分割与列异常处理的python脚本
    小程序例子
  • 原文地址:https://www.cnblogs.com/hujie-developer/p/5753909.html
Copyright © 2020-2023  润新知