1

SpringSecurityを2から3にアップグレードしました

以前のSecurity.xmlには、 AuthenticationProcessingFilterAuthenticationProcessingFilterEntryPointがあります

つまり、私の新しいSecurity.xmlは

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
<beans:bean id="userAuthenticationService"
    class="com.raykor.core.service.UserAuthenticationService" />

<beans:bean id="shaEncoder"
    class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />

<global-method-security />

<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint">

    <intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" />
    <intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" />
    <logout logout-success-url="/index.jsp" invalidate-session="true" />
</http>

<authentication-manager alias="authenticationManager">
    <authentication-provider user-service-ref="userAuthenticationService">
        <password-encoder ref="shaEncoder">
            <salt-source user-property="salt" />
        </password-encoder>
    </authentication-provider>
</authentication-manager>

<beans:bean id="authenticationFilter"
    class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
    <beans:property name="filterProcessesUrl" value="/j_spring_security_check" />
    <beans:property name="authenticationManager" ref="authenticationManager" />
    <beans:property name="authenticationFailureHandler"
        ref="failureHandler" />
    <beans:property name="authenticationSuccessHandler"
        ref="successHandler" />
</beans:bean>

<beans:bean id="successHandler"
    class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <beans:property name="alwaysUseDefaultTargetUrl" value="false" />
    <beans:property name="defaultTargetUrl" value="/home.do" />
</beans:bean>

<beans:bean id="failureHandler"
    class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
    <beans:property name="defaultFailureUrl" value="/login.do?error=true" />
</beans:bean>

<beans:bean id="authenticationProcessingFilterEntryPoint"
    class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
    <beans:property name="loginFormUrl" value="/login.do" />
    <beans:property name="forceHttps" value="false" />
</beans:bean>

`

また、web.xmlにフィルターspringSecurityFilterChainを追加しました

login.doでログインページを開き、送信時にユーザー名とパスワードをj_usernamej_passwordとしてj_spring_security_checkに送信します

では、なぜj_spring_security_checknotavailableと言っているのですか?

4

2 に答える 2

1

をインスタンス化しますがUsernamePasswordAuthenticationFilter、作成しただけではセキュリティフィルターチェーンの一部にはなりません。config要素auto-config="false"からを削除してみて、その中に要素を含めてください。Bean定義を介して行ったすべての構成は、SpringSecurity3で推奨されるより簡潔な名前空間構成を使用して行うことができると思います。http<form-login>

于 2013-03-04T11:39:42.773 に答える
1

更新したカスタムフィルター参照を追加できませんでした

<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint">
    <custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter"/>
    <intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" />
    <intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" />
    <logout logout-success-url="/index.jsp" invalidate-session="true" />
</http>
于 2013-03-04T11:46:12.140 に答える