@Test public void testGetConfigAttributesByUrl_假如存在如上资源信息_当请求存在的资源时_那么返回url和method都匹配的资源信息() { AuthenticationService authenticationService = new AuthenticationService(this.resourceConfigAttributes); ConfigAttribute attributesByUrl = authenticationService .findConfigAttributesByUrl(new HttpServletRequestAuthWrapper(new MockHttpServletRequest(), "/users", "POST")); Assert.assertEquals("user_manager:btn_add", attributesByUrl.getAttribute()); }
public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return this.resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> this.resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig(NONEXISTENT_URL)); }
AuthenticationService implements IAuthenticationService { public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return this.resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> this.resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig(NONEXISTENT_URL)); } }
AuthenticationService implements IAuthenticationService { public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return this.resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> this.resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig(NONEXISTENT_URL)); } @Autowired  AuthenticationService(Map<RequestMatcher, ConfigAttribute> resourceConfigAttributes); }
AuthenticationService implements IAuthenticationService { public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return this.resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> this.resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig(NONEXISTENT_URL)); } @Autowired  AuthenticationService(Map<RequestMatcher, ConfigAttribute> resourceConfigAttributes); @Override boolean decide(HttpServletRequest authRequest); boolean isMatch(ConfigAttribute urlConfigAttribute, Set<Resource> userResources); ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest); }
AuthenticationService implements IAuthenticationService { public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return this.resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> this.resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig(NONEXISTENT_URL)); } @Autowired  AuthenticationService(Map<RequestMatcher, ConfigAttribute> resourceConfigAttributes); @Override boolean decide(HttpServletRequest authRequest); boolean isMatch(ConfigAttribute urlConfigAttribute, Set<Resource> userResources); ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest); static final String NONEXISTENT_URL; }