2012-11-09 40 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> 
相關問題