Spring 2.5.6 と Spring Security 2.0.4 を使用する Web アプリケーションがあります。Web サービスに対してユーザーを認証するログイン ページを実装しました。認証は、次のようにカスタム認証マネージャーを定義することによって行われます。
<beans:bean id="customizedFormLoginFilter"
class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
<custom-filter position="AUTHENTICATION_PROCESSING_FILTER" />
<beans:property name="defaultTargetUrl" value="/index.do" />
<beans:property name="authenticationFailureUrl" value="/login.do?error=true" />
<beans:property name="authenticationManager" ref="customAuthenticationManager" />
<beans:property name="allowSessionCreation" value="true" />
</beans:bean>
<beans:bean id="customAuthenticationManager"
class="com.sevenp.mobile.samplemgmt.web.security.CustomAuthenticationManager">
<beans:property name="authenticateUrlWs" value="${WS_ENDPOINT_ADDRESS}" />
</beans:bean>
認証マネージャ クラス:
public class CustomAuthenticationManager implements AuthenticationManager, ApplicationContextAware {
@Transactional
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
//authentication logic
return new UsernamePasswordAuthenticationToken(principal, authentication.getCredentials(),
grantedAuthorityArray);
}
ログイン JSP の重要な部分は次のようになります。
<c:url value="/j_spring_security_check" var="formUrlSecurityCheck"/>
<form method="post" action="${formUrlSecurityCheck}">
<div id="errorArea" class="errorBox">
<c:if test="${not empty param.error}">
${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
</c:if>
</div>
<label for="loginName">
Username:
<input style="width:125px;" tabindex="1" id="login" name="j_username" />
</label>
<label for="password">
Password:
<input style="width:125px;" tabindex="2" id="password" name="j_password" type="password" />
</label>
<input type="submit" tabindex="3" name="login" class="formButton" value="Login" />
</form>
問題は、アプリケーションがSpring Web Flowを使用する必要があることです。アプリケーションが Spring Web Flow を使用するように構成された後、ログインが機能しなくなります。「/j_spring_security_check」へのフォーム アクションにより、エラー メッセージのない空白のページが表示されます。Spring Web Flow で動作するように既存のログイン プロセスを適応させる最良の方法は何ですか?
編集:エラー メッセージは表示されず、空白のページが表示されました。現在は動作しています - 問題は、web.xml にエントリがないことでした
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
問題は解決しましたが、報奨金をキャンセルすることはできないため、Spring Security と Web Flow を連携するように他の人が構成するのに役立つ、最も洞察に満ちた回答またはリンクに報奨金が授与されます。