Spring Securityを使用してNTLMを実行していますが、次のエラーが表示されます
org.springframework.beans.factory.NoSuchBeanDefinitionException:「springSecurityFilterChain」という名前のBeanは定義されていません
このエラーを解決するにはどうすればよいですか?
Web.xmlで次のものが定義されています
<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>
アップデート1
私はそのエラーを解決しました、今私は
org.springframework.beans.factory.NoSuchBeanDefinitionException:「filterSecurityInterceptor」という名前のBeanは定義されていません
私は次のものを持っています
<bean id="springSecurityFilterChain" class="org.acegisecurity.util.FilterChainProxy">
<property name="filterInvocationDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_Apache_ANT
/**=httpSessionContextIntegrationFilter, exceptionTranslationFilter, ntlmFilter, filterSecurityInterceptor
</value>
</property>
</bean>`
@Sean Patrick Floydが言ったように、いくつかの要素は古くて死んでいて埋められていたので、applicationContext.xmlを次のように変更しました。しかし、私は修正する必要がある他のエラーがあります:-)
ありがとう
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
<!--<authentication-manager alias="_authenticationManager"></authentication-manager>-->
<security:authentication-provider>
<security:user-service>
<security:user name="testuser" password="PASSWORD" authorities="ROLE_USER, ROLE_ADMIN"/>
<security:user name="administrator" password="PASSWORD" authorities="ROLE_USER,ROLE_ADMIN"/>
</security:user-service>
</security:authentication-provider>
<bean id="userDetailsAuthenticationProvider"
class="com.icesoft.icefaces.security.UserDetailsAuthenticationProvider">
<security:custom-authentication-provider/>
</bean>
<bean id="ntlmEntryPoint"
class="org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint">
<property name="authenticationFailureUrl" value="/accessDenied.jspx"/>
</bean>
<bean id="ntlmFilter" class="org.springframework.security.ui.ntlm.NtlmProcessingFilter">
<security:custom-filter position="NTLM_FILTER"/>
<property name="stripDomain" value="true"/>
<property name="defaultDomain" value="domain"/>
<property name="netbiosWINS" value="domain"/>
<property name="authenticationManager" ref="_authenticationManager"/>
</bean>
<bean id="exceptionTranslationFilter"
class="org.springframework.security.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint" ref="ntlmEntryPoint"/>
</bean>
<security:http access-decision-manager-ref="accessDecisionManager"
entry-point-ref="ntlmEntryPoint">
<security:intercept-url pattern="/accessDenied.jspx" filters="none"/>
<security:intercept-url pattern="/**" access="ROLE_USER"/>
</security:http>
<bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
<property name="allowIfAllAbstainDecisions" value="false"/>
<property name="decisionVoters">
<list>
<bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
</list>
</property>
</bean>
</beans>
DelegatingFilterProxy
ドキュメントから:
フィルターは実際にはDelegatingFilterProxyであり、実際にフィルターのロジックを実装するクラスではないことに注意してください。 DelegatingFilterProxyが行うことは、Springアプリケーションコンテキストから取得したBeanにフィルターのメソッドを委任するです。これにより、BeanはSpring Webアプリケーションコンテキストのライフサイクルサポートと構成の柔軟性の恩恵を受けることができます。 Beanはjavax.servlet.Filterを実装する必要があり、filter-name要素の名前と同じ名前でなければなりません。詳細については、DelegatingFilterProxyのJavadocをご覧ください
アプリケーションコンテキストでjavax.servlet.Filter
を実装するspringSecurityFilterChain
という名前のBeanを定義する必要があります。
フレームワークの名前空間前のバージョンに精通している場合は、おそらくここで何が起こっているかおおよそ推測できます。
<http>
要素は、FilterChainProxy
および使用するフィルターBeanの作成を担当します。フィルターの位置が事前に定義されているため、誤ったフィルターの順序などの一般的な問題はもう問題ではありません。
したがって、少なくとも 最小<http>
構成 が必要です。
ショーン・パトリック・フロイドは絶対に正しいが、私はそれを言及する価値があると思う、それは私にとって多くの時間を要した。
@ImportResourceアノテーションを追加するだけです。
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"org.company"})
@ImportResource({"classpath:security.xml"})
public class CompanyWebMvcConfiguration extends WebMvcConfigurerAdapter {
}
security.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true">
<access-denied-handler error-page="/error"/>
</http>
Java構成では、次の注釈を使用できます。
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
public class MySecurityConfig extends WebSecurityConfigurerAdapter {
}
これにより、springSecurityFilterChain
Beanを定義するorg.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration
構成クラスがインポートされます。
最小限の設定で春のセキュリティファイルを提供してください
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/securityhttp:// www .springframework.org/schema/security/spring-security-3.0.3.xsd ">
<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
</http>