2011-05-27 36 views
2

在我部署的一隻耳朵。我有一個安全上下文,像這樣:如何重定向到登錄進入點在不同的EAR

<security:http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint"> 
    <security:intercept-url pattern="/login" filters="none" /> 
    <security:intercept-url pattern="/**" access="isAuthenticated() and permitAll" /> 

    <security:custom-filter position="FORM_LOGIN_FILTER" ref="ssoFilter" /> 
</security:http> 
<bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"> 

    <property name="loginFormUrl" value="/login"/> 
</bean> 

現在,在第二EAR我想重定向到登錄第一個頁面。這可以以某種方式完成,而不需要擴展LoginUrlAuthenticationEntryPoint

因爲目前如果我嘗試在第二EAR安全上下文絕對URL:

<property name="loginFormUrl" value="http://host/ear1ContextPath/login"/> 

我重定向到:http://host/ear2contextPath/login

這是不正確的。

感謝

+0

你能描述一下你的情況嗎? – abalogh 2011-05-27 09:54:54

+0

@abalogh單點登錄,第一個EAR登錄URL將成爲所有其他系統的入口點。 – Simeon 2011-05-27 11:01:19

+1

http://forum.springsource.org/showthread.php?105771-Integrate-Single-Sign-On-using-Spring-Security->檢查此 – abalogh 2011-05-27 11:35:44

回答

1

我設法通過實現我自己的UrlAuthenticationFaliureHandler和編程處理絕對URL來做到這一點(只是做一個servlet重定向再破過濾器鏈)。

然後,我可以注入新的FailureHandler在我的自定義過濾器是這樣的:

<bean id="absoluteUrlLoginFailureHandler" class="tld.company.AbsoluteUrlAuthenticationFaliureHandler"> 

    <property name="defaultFailureUrl" value="http://company.domain.tld/Login.html"/> 
</bean> 
<bean id="absoluteUrlFilter" class="tld.company.MyUserPassFilter"> 

    <property name="authenticationFailureHandler" ref="absoluteUrlLoginFailureHandler"/>    
</bean> 

然後我設置的命名空間配置該過濾器:

<http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint"> 
    <security:intercept-url pattern="/**" access="isAuthenticated() and permitAll" /> 

    <custom-filter position="FORM_LOGIN_FILTER" ref="absoluteUrlFilter" /> 
</http> 

<entry-point-ref>元素似乎處理絕對網址默認情況下。

相關問題