1 2 3 4 5 | public class FingerPrintToken implements Authentication { private String name; private String fingerPrint; ...... } |
1 2 3 4 5 6 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (Objects.equals(httpServletRequest.getRequestURI(), "/api/finger-print")) { // 调用 AuthenticationManager, 并填充 SecurityContext } } |
1 2 3 4 5 6 7 8 | protected void configure(HttpSecurity http) throws Exception { http .userDetailsService(userDetailsService()) .addFilterAfter(fingerPrintFilter(), SecurityContextPersistenceFilter.class) .authenticationProvider(fingerPrintProvider()) .authorizeRequests() .mvcMatchers(HttpMethod.GET, "/api/test").authenticated() } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |