2

JBoss WildFly 10.0.0.CR2 で Spring 3.2.11.RELEASE と Spring Security 3.1.4.RELEASE を使用しています。アプリケーションコンテキストで次のように設定しています...

<beans:bean id="springboardUsernamePasswordUrlAuthenticationFilter" class="org.mainco.subco.core.security.SubcoUsernamePasswordUrlAuthenticationFilter">
    <beans:property name="filterProcessesUrl" value="/j_spring_security_check"/>
    <beans:property name="authenticationManager" ref="authenticationManager"/>
    <beans:property name="authenticationFailureHandler">
        <beans:bean class="org.mainco.subco.myproject.security.SubcoAuthenticationFailureHandler">
            <beans:property name="defaultFailureUrl" value="/login/failure"/>
            <beans:property name="userService" ref="userService" />
        </beans:bean>
    </beans:property> 
    <beans:property name="authenticationSuccessHandler">
        <beans:bean class="org.mainco.subco.myproject.security.SubcoAuthenticationSuccessHandler">
            <beans:property name="defaultTargetUrl" value="/success"/>
            <beans:property name="userService" ref="userService" />
            <beans:property name="sessionService" ref="sessionService" />
        </beans:bean>
    </beans:property>      
</beans:bean>

間違ったユーザー名とパスワードの組み合わせを入力すると失敗ハンドラーが呼び出され、正しいユーザー名とパスワードの組み合わせを入力すると成功ハンドラーが呼び出され、最終的に以下のメソッドが呼び出されることに気付きました…</p>

@RequestMapping(value = "/success")
public String authenticate(final Principal principal)
{
     …
} 

これは私のweb.xmlで構成されています。Spring セキュリティ フィルターは問題の成功 URL をキャッチすることに注意してください…</p>

<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>
<filter>
   <filter-name>CSRFGuard</filter-name>
   <filter-class>org.owasp.csrfguard.CsrfGuardFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>CSRFGuard</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

ただし、上記のメソッドが呼び出されると、「プリンシパル」オブジェクトが null になるため、ログインしているユーザーを特定できません。Spring では、ログインが成功したときにプリンシパル オブジェクトを設定するメカニズムは何ですか? 正しくログインできるように見えるのに、認証オブジェクトが設定されていないのはなぜですか?

4

0 に答える 0