0

我使用了 jasig (3.5.1) cas sever 并成功配置。它工作正常。我的项目有另一个要求。我在下面提到它我需要另一个登录机制。这意味着我需要企业用户的公司代码、手机号码和密码验证,而不是使用用户名密码。所以我为此创建了另一个凭据类

public class CodeMobileNumberCredintials implements Credentials{
@NotNull
    @Size(min=1,message = "required.code")
    private String code;

    @NotNull
    @Size(min=1, message = "required.mobileNumber")
    private String mobileNumber;

    @NotNull
    @Size(min=1, message = "required.password")
    private String password;
...
}

Then i created a variable called "codeMobileNumberCredintials"in web-flow.

    <var name="credentials" class="org.jasig.cas.authentication.principal.UsernamePasswordCredentials" />
        <var name="codeMobileNumberCredintials" class="org.jasig.cas.authentication.principal.CodeMobileNumberCredintials"/>

     <view-state id="viewCorporateLoginForm" view="casCorporateLoginView" model="codeMobileNumberCredintials">
            <binder>
                <binding property="code" />
                <binding property="mobileNumber" />
                <binding property="password" />
            </binder>
            <on-entry>
                <set name="viewScope.commandName" value="'codeMobileNumberCredintials'" />
            </on-entry>
            <transition on="submit" bind="true" validate="true" to="realCorporateSubmit">
                <evaluate expression="authenticationViaFormAction.doCorporateBind(flowRequestContext, flowScope.codeMobileNumberCredintials)" />
            </transition>
        </view-state>

问题是 bean 验证过程不适用于我的自定义登录表单。但正常的用户名密码表单已验证(提交表单时没有给出用户名和密码,它显示“用户名和密码空白”)。但是我的自定义身份验证表单没有经过验证。它直接进入控制器类。
我花了很多时间来做这件事。谁能帮我完成我的任务。

Thank you
Amila
4

2 回答 2

1

我有一个类似的问题。解决它的最简单方法是在 cas-server-webapp 模块的 cas-servlet.xml Spring 配置文件中添加新的验证器 bean。在您的情况下,它将是:

      <bean id="codeMobileNumberCredintialsValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"
    p:messageInterpolator-ref="messageInterpolator" />
于 2012-11-30T08:44:03.160 回答
0

Spring Web Flow 存在问题,导致验证期间出错。它发生如下堆栈跟踪并显示错误页面,而不是重新显示登录表单:

2013-10-04 09:48:31,683 TRACE [org.jasig.cas.web.init.SafeDispatcherServlet] - <Entering method [service with arguments [[org.apache.catalina.connector.RequestFacade@411c345a, org.apache.catalina.connector.ResponseFacade@22b1221b]]>
2013-10-04 09:48:31,686 DEBUG [org.jasig.cas.web.FlowExecutionExceptionResolver] - <Ignoring the received exception due to a type mismatch> org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException: Badly formatted flow execution key '[Ljava.lang.String;@58714e00', the expected format is 'e<executionId>s<snapshotId>'

此处描述了该修复程序CAS-1142。它对我有帮助,它总结为在 cas-servlet.xml 中添加一行<webflow:redirect-in-same-state value="false" />,结果如下:

    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    <webflow:flow-execution-attributes>
        <webflow:always-redirect-on-pause value="false"/>
        <webflow:redirect-in-same-state value="false" />
    </webflow:flow-execution-attributes>
    <webflow:flow-execution-listeners>
        <webflow:listener ref="terminateWebSessionListener" />
    </webflow:flow-execution-listeners>
</webflow:flow-executor>
于 2013-10-04T07:52:54.330 回答