2017-05-21 3 views
0

WebアプリケーションにSpring SAMLを実装していますが、すでに春セキュリティが実装されています。 Springは常に最後に宣言されたauthenticationManagerを参照するので、私はbeanとして1つのauthenticationManagerを定義する解決策を見いだしました。authenticationManagerをBeanとして書き込む方法(SAMlAuthenticationManagerをBeanに変換する)

後Beanへ変換する前に、私のAuthenticationManagerた:後

<authentication-manager alias="samlAuthenticationManager"> 
    <!-- Register authentication manager for SAML provider --> 
    <authentication-provider ref="samlAuthenticationProvider"/> 
    <!-- Register authentication manager for administration UI --> 
    <authentication-provider> 
     <user-service id="adminInterfaceService"> 
      <user name="admin" password="admin" authorities="ROLE_ADMIN"/> 
     </user-service> 
    </authentication-provider> 
</authentication-manager> 

はBeanに変換した後、私のコードである:

<beans:bean id="samlAuthenticationManager" class="org.springframework.security.authentication.ProviderManager"> 
    <beans:constructor-arg> 
     <beans:list> 
      <beans:bean class="org.springframework.security.saml.SAMLAuthenticationProvider"> 
       <beans:property name="userDetails" value="adminInterfaceService"/> 
      </beans:bean> 
     </beans:list> 
    </beans:constructor-arg> 
</beans:bean> 
<user-service id="adminInterfaceService"> 
    <user name="admin" password="admin" authorities="ROLE_ADMIN"/> 
</user-service> 

認証プロバイダは、次のように定義:

<beans:bean id="samlAuthenticationProvider" class="org.springframework.security.saml.SAMLAuthenticationProvider"> 
     <!-- OPTIONAL property: can be used to store/load user data after login --> 
     <!-- 
     <beans:property name="userDetails" ref="bean" /> 
     --> 
</beans:bean> 

私は次のようになっています:

必要なタイプ に 'org.springframework.security.saml.userdetails.SAMLUserDetailsS​​ervice' プロパティをタイプ 'はjava.lang.String型' の値を変換できません 'userDetails'

について助けてください同じ。私は非常に義務づけられます。事前に

おかげで

答えて

0

https://github.com/spring-projects/spring-security/issues/2163

ちょうど

あなたは春の豆を使用する必要はありません認証マネージャの両方に代わりにエイリアスのIDを使用していたここに解決策を見つけました。 IDを指定しない場合、 は「デフォルト」インスタンスを上書きします。これは、標準のSpring Beanが動作する方法とほぼ同じです。参照されるスレッドでは、ユーザは IDではなくエイリアスを指定しているため、別のインスタンス は作成されません。繰り返しますが、通常のBeanインスタンスが動作する方法です。 私はそれから逸脱するべきかどうかはわかりません。

関連する問題