【问题标题】:Spring custom authentication manager (with custom user details service)Spring 自定义身份验证管理器(带有自定义用户详细信息服务)
【发布时间】:2015-07-05 09:47:28
【问题描述】:

在我的 Spring 应用程序中,我希望我的 ProviderManager 类实现 Serializable 类(出于我自己的原因),当然我们不能编辑 Spring 代码,所以我做的一种方法是使用一个名为 CustomProviderManager 的自定义类来扩展ProviderManager 并实现 Serializable 类。
我对身份验证管理器的旧声明喜欢这样:

    <security:authentication-manager alias="authenticationManager">
      <security:authentication-provider
        user-service-ref="customUserDetailsService" >
        <security:password-encoder hash="md5" />
      </security:authentication-provider>
    </security:authentication-manager>

如何为我的 CustomProviderManager 类配置上面 sn-p 的喜欢(我的自定义身份验证管理器的身份验证提供程序应使用自定义用户详细信息服务名称“customUserDetailsS​​ervice”,密码编码器为“ md5")

【问题讨论】:

    标签: spring-security


    【解决方案1】:

    取决于您的 CustomProviderManager,但类似这样:

    <bean id="authenticationManager" class="CustomProviderManager">
      <constructor-arg>
        <bean class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
          <property name="userDetailsService" ref="customUserDetailsService"/>
          <property name="passwordEncoder">
            <bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>
          </property>
        </bean>
      </constructor-arg>
    </bean>
    

    【讨论】:

    • 虽然有点晚了,但是感谢您的解决方案:)
    猜你喜欢
    • 2012-05-23
    • 2017-12-11
    • 1970-01-01
    • 2018-10-25
    • 2017-07-16
    • 1970-01-01
    • 2019-06-01
    • 2011-06-24
    • 1970-01-01
    相关资源
    最近更新 更多