2016-05-12 40 views
0

Spring WebアプリケーションでPreAuthenticationFilterを設定しようとしています。私はこのofficial guideを、以下、セクションで探していますSpring Security Preauthentication Config

18.2.1リクエスト・ヘッダー認証(Siteminderの)ここで

は私の豆と構成の概要を説明し、私の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-4.1.xsd 
           http://www.springframework.org/schema/security 
           http://www.springframework.org/schema/security/spring-security-4.0.xsd" 
     xmlns:context="http://www.springframework.org/schema/context"> 

<beans:bean id="myFilter" class="com.MyFilter"> 
    <beans:property name="authenticationManager" ref="authenticationManager" /> 
</beans:bean> 

<beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> 
    <beans:property name="preAuthenticatedUserDetailsService"> 
     <beans:bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> 
     <beans:property name="userDetailsService" ref="userDetailsService"/> 
     </beans:bean> 
    </beans:property> 
</beans:bean> 

<authentication-manager alias="authenticationManager"> 
    <authentication-provider ref="preauthAuthProvider" /> 
</authentication-manager> 

<http auto-config="true" use-expressions="true" pattern="/**" > 
    <intercept-url pattern="/main/data" access="hasAnyRole('ROLE_ADMINISTRATORS')" requires-channel="https" /> 
    <intercept-url pattern="/**" access="isAuthenticated()" requires-channel="any" /> 
    <http-basic /> 
</http> 

基本的に、私はガイドからchaningています唯一の事は私のfilterIdとクラスです。他のすべては同じです。

私は取得していますエラーはこれです:私はここ

Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userDetailsService' is defined 

何をしないのですか?そのクラスはすでに私のプロジェクトに入っているSpring Jarにあり、どのクラスにもインポートできます。

答えて

1

userDetailsServiceを参照して、プロパティをname userDetailsServiceに設定すると、次の行に表示されます。

<beans:property name="userDetailsService" ref="userDetailsService"/> 

は、だから、ID userDetailsService次のようにあなたのsecurity.xmlファイル内のいくつかの場所でBeanを宣言している必要があります。しかし、私はそのような豆を見ません。例えば

<bean id="userDetailsService" class="org.xxx.xxx"> 
</bean> 

あなたがref豆preauthAuthProviderを持っていて、それが

<beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> 
+0

ため息を参照​​する必要があり、あなたは正しいです。あなたが独自のuserdetailserviceを実装しなければならないことを意味する小さなフットプリントが欠けていました。 grails 3プラグインでは、同じことをしますが、そうではありません。したがって、小さな矛盾が問題を引き起こしました。 – angryip