カスタム認証マネージャーが自動配線されない理由を突き止めようと必死になって数時間を過ごした後、少し助けを求めてここに来ました。これで、Spring (Stripes を使用) で実行される Web アプリケーションができました。認証はカスタム クラスによって行われます。すべて正常に動作します - jsp では、jsp タグを使用でき、すべての http インターセプターが正常に動作します。しかし、認証マネージャーをジャージーの「RESTクラス」に自動配線しようとすると、すべてがうまくいかず、何も注入されません。
したがって、Web xml には両方のコンテキスト ファイルがあります。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-context.xml
/WEB-INF/spring-security.xml
</param-value>
</context-param>
春のセキュリティ.xml:
<context:component-scan base-package="org.springframework.security" />
<context:annotation-config/>
<http use-expressions="true" auto-config="true">
</http>
<authentication-manager alias="authManager">
<authentication-provider ref="AuthenticationManagerBean" />
</authentication-manager>
<beans:bean id="AuthenticationManagerBean" class="com.manager.services.MyAuthenticationManager"/>
<beans:bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler" />
そして、Jersey アクション Bean の内部は次のようなものです。
@Inject
@Qualifier("authManager")
protected AuthenticationManager authenticationManager;
アプリケーション全体が正常にビルドされ、Jetty サーバーが問題なく起動します (MyAuthenticationManager と org.springframework.security.authenticationManager の両方が正常に事前設定されています) が、autowired authmanager を使用しようとすると、null ポインターが取得されます。
編集: AuthenticationManager を Stripes のアクション Bean に自動配線することに成功しましたが、Jersey のアクション Bean にはまだ問題があり、@Inject @Qualifier(...) の構築は AuthManager では機能しません (ただし、@Qualifier がなくても、他の自動配線された Bean では機能します) 、@Injectのみ)。
編集 2: Spring が authenticationManager を Jersey Beans に挿入しない理由を数時間調べた後、次の方法で問題を解決しました。
@Inject
@InjectParam("org.springframework.security.authenticationManager")
protected AuthenticationManager authenticationManager;
それが良い解決策であるかどうかはわかりませんが、機能しており、スプリングは正しい認証マネージャーを挿入するようになりました。