У меня есть требование динамического внедрения AuthenticationProviders во время выполнения с использованием конфигурации файла свойств.
Я создал auth.properties:
enable.providers= provider1, provider2
Аннотации класса провайдера
@Component(value="allowAllAuthenticationProvider")
@Conditional(AllowAllAuthProviderCondition.class)
У всех провайдеров есть @Component @Condition на уровне класса для загрузки бинов, если он настроен.
Таким образом, бины загружаются согласно конфигурации файла свойств.
Теперь я не являюсьв состоянии добавить этих провайдеров в authenticationManager.Я испробовал почти все варианты.
@Bean( name= {"authenticationManager"})
public AuthenticationManager authenticationManager()
{
return new ProviderManager(providers);
}
Пожалуйста, помогите мне, как достичь своей цели по внедрению поставщиков аутентификации в диспетчер аутентификации во время выполнения.
<spring-security:http use-expressions="true" auto-config="true" realm="User Restrict Realm" >
<spring-security:intercept-url
pattern="/camel/**" access="hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')" />
<spring-security:http-basic />
</spring-security:http>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg>
<list>
<!-- <bean class="org.springframework.security.access.vote.AuthenticatedVoter" />
<bean class="org.springframework.security.access.vote.RoleVoter" /> -->
<bean class="com.rnd.camel.rest.security.util.MyVoter" />
</list>
</constructor-arg>
<property name="allowIfAllAbstainDecisions" value="true" />
</bean>
<authorizationPolicy id="admin" access="ROLE_ADMIN"
authenticationManager="authenticationManager" accessDecisionManager="accessDecisionManager"
xmlns="http://camel.apache.org/schema/spring-security" />
<authorizationPolicy id="user" access="ROLE_USER"
authenticationManager="authenticationManager" accessDecisionManager="accessDecisionManager"
xmlns="http://camel.apache.org/schema/spring-security" />