2012-11-09 119 views
0

我已经使用jasig(3.5.1)cas服务器并成功配置。它工作正常。我的项目有另一个要求。我在下面提到它 我需要另一个登录机制。这意味着,而不是使用立场用户名密码,我需要企业用户的公司代码,手机号码和密码认证。所以我创造了该Jasig cas如何验证视图状态下的自定义模型属性

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验证过程中工作不适合我的自定义登录form.But正常的用户名密码验证的形式(submiting没有得到安宁的用户名和密码的形式时,它说:“用户名和密码空白“)。但是我的自定义验证表单未经验证,直接进入控制器类。
我花了很多时间来做到这一点。任何人都可以帮助我完成我的任务。

Thank you 
Amila 

回答

1

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

 <bean id="codeMobileNumberCredintialsValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" 
    p:messageInterpolator-ref="messageInterpolator" /> 
0

有一个弹簧网络流量的问题,导致验证过程中的错误。它发生与所显示的,而不是重新显示登录表单如下堆栈跟踪和错误页:

2013-10-04 09:48:31,683 TRACE [org.jasig.cas.web.init.SafeDispatcherServlet] - <Entering method [service with arguments [[[email protected], [email protected]]]> 
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说明。它帮助我,它总结与增加一行<webflow:redirect-in-same-state value="false" /> cas-servlet.xml产生如下:

<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> 
相关问题