我不确定我是否完全理解您的问题,但如果我理解正确,您可以扩展 AbstractPreAuthenticatedProcessingFilter 并通过调用您的 restful 服务/控制器等覆盖 getPreAuthenticatedPrincipal 和 getPreAuthenticatedCredentials。覆盖 AuthenticationUserDetailsService 并提供一个简单的服务,并添加您的安全上下文,如下所示:
<beans:bean id="preauthAuthProvider"
class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
<beans:property name="preAuthenticatedUserDetailsService">
<beans:bean class="com.YourCompany.YourPreAuthenticatedGrantedAuthoritiesUserDetailsService"></beans:bean>
</beans:property>
<beans:property name="order" value="1"/>
</beans:bean>
<authentication-manager alias="authenticationManager" >
<authentication-provider ref="preauthAuthProvider" ></authentication-provider>
</authentication-manager>