當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestMatcher類代碼示例

本文整理匯總了Java中org.springframework.security.web.util.matcher.RequestMatcher的典型用法代碼示例。如果您正苦於以下問題:Java RequestMatcher類的具體用法?Java RequestMatcher怎麽用?Java RequestMatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestMatcher類屬於org.springframework.security.web.util.matcher包,在下文中一共展示了RequestMatcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Override
protected void configure(HttpSecurity http) throws Exception {
	// secure endpoints
	RequestMatcher matcher = getRequestMatcher();
	if (matcher != null) {
		// Always protect them if present
		if (this.security.isRequireSsl()) {
			http.requiresChannel().anyRequest().requiresSecure();
		}
		AuthenticationEntryPoint entryPoint = entryPoint();
		http.exceptionHandling().authenticationEntryPoint(entryPoint);
		// Match all the requests for actuator endpoints ...
		http.requestMatcher(matcher);
		// ... but permitAll() for the non-sensitive ones
		configurePermittedRequests(http.authorizeRequests());
		http.httpBasic().authenticationEntryPoint(entryPoint);
		// No cookies for management endpoints by default
		http.csrf().disable();
		http.sessionManagement().sessionCreationPolicy(
				this.management.getSecurity().getSessions());
		SpringBootWebSecurityConfiguration.configureHeaders(http.headers(),
				this.security.getHeaders());
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:25,代碼來源:ManagementWebSecurityAutoConfiguration.java

示例2: configure

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Override
protected void configure(HttpSecurity http) throws Exception {
    List<RequestMatcher> csrfMethods = new ArrayList<>();
    Arrays.asList( "POST", "PUT", "PATCH", "DELETE" )
            .forEach( method -> csrfMethods.add( new AntPathRequestMatcher( "/**", method ) ) );
    http
            .sessionManagement().sessionCreationPolicy( SessionCreationPolicy.STATELESS ).and()
            .exceptionHandling().authenticationEntryPoint( restAuthenticationEntryPoint ).and()
            .authorizeRequests()
            .antMatchers(
                    HttpMethod.GET,
                    "/",
                    "/webjars/**",
                    "/*.html",
                    "/favicon.ico",
                    "/**/*.html",
                    "/**/*.css",
                    "/**/*.js"
            ).permitAll()
            .antMatchers("/auth/**").permitAll()
            .anyRequest().authenticated().and()
            .addFilterBefore(new TokenAuthenticationFilter(tokenHelper, jwtUserDetailsService), BasicAuthenticationFilter.class);

    http.csrf().disable();
}
 
開發者ID:bfwg,項目名稱:springboot-jwt-starter,代碼行數:26,代碼來源:WebSecurityConfig.java

示例3: isNeedToVerify

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
private boolean isNeedToVerify(HttpServletRequest request) {
    for (RequestMatcher matcher : authRequests) {
        if (matcher.matches(request)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:9,代碼來源:AuthenticationInterceptor.java

示例4: authInterceptor

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Bean
public AuthenticationInterceptor authInterceptor() {
    List<RequestMatcher> matchers = ImmutableList.of(
        new AntPathRequestMatcher("/flows/**"),
        new AntPathRequestMatcher("/user/register"),
        new AntPathRequestMatcher("/user/delete"),
        new AntPathRequestMatcher("/user"),
        new AntPathRequestMatcher("/user/role/update"),
        new AntPathRequestMatcher("/jobs/**"),
        new AntPathRequestMatcher("/credentials/*"),
        new AntPathRequestMatcher("/actions/**"),
        new AntPathRequestMatcher("/message/**"),
        new AntPathRequestMatcher("/agents/create"),
        new AntPathRequestMatcher("/agents"),
        new AntPathRequestMatcher("/roles/**"),
        new AntPathRequestMatcher("/thread/config")
    );
    return new AuthenticationInterceptor(matchers);
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:20,代碼來源:WebConfig.java

示例5: RequestConfigMapping

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
public RequestConfigMapping(RequestMatcher matcher, Collection<ConfigAttribute> attributes) {
    if (matcher == null) {
        throw new IllegalArgumentException("matcher cannot be null");
    }
    Assert.notEmpty(attributes, "attributes cannot be null or emtpy");

    this.matcher = matcher;
    this.attributes = attributes;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:10,代碼來源:RequestConfigMapping.java

示例6: getRequestMatcher

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
public static RequestMatcher getRequestMatcher(
		ManagementContextResolver contextResolver) {
	if (contextResolver == null) {
		return null;
	}
	ManagementServerProperties management = contextResolver
			.getApplicationContext().getBean(ManagementServerProperties.class);
	ServerProperties server = contextResolver.getApplicationContext()
			.getBean(ServerProperties.class);
	String path = management.getContextPath();
	if (StringUtils.hasText(path)) {
		AntPathRequestMatcher matcher = new AntPathRequestMatcher(
				server.getPath(path) + "/**");
		return matcher;
	}
	// Match everything, including the sensitive and non-sensitive paths
	return new LazyEndpointPathRequestMatcher(contextResolver, EndpointPaths.ALL);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:ManagementWebSecurityAutoConfiguration.java

示例7: buildSecurityMetadataSource

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
/****
	 * 基於url匹配攔截時,轉換為ExpressionBasedFilterInvocationSecurityMetadataSource
	 * @param source
	 * @return
	 */
	@Override
	@SuppressWarnings("unchecked")
	public void buildSecurityMetadataSource(){
		Assert.notNull(filterSecurityInterceptor);
		this.buildRequestMap();
		DefaultFilterInvocationSecurityMetadataSource originMetadata = (DefaultFilterInvocationSecurityMetadataSource)filterSecurityInterceptor.getSecurityMetadataSource();
		//這個內置實現不支持一個url映射到多個表達式
//		ExpressionBasedFilterInvocationSecurityMetadataSource fism = new ExpressionBasedFilterInvocationSecurityMetadataSource(requestMap, securityExpressionHandler);
		
		Map<RequestMatcher, Collection<ConfigAttribute>> originRequestMap = (Map<RequestMatcher, Collection<ConfigAttribute>>)ReflectUtils.getFieldValue(originMetadata, "requestMap", false);
		if(originRequestMap!=null && !originRequestMap.isEmpty()){
			this.requestMap.putAll(originRequestMap);
		}
		DefaultFilterInvocationSecurityMetadataSource fism = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
		this.filterSecurityInterceptor.setSecurityMetadataSource(fism);
	}
 
開發者ID:wayshall,項目名稱:onetwo,代碼行數:22,代碼來源:DatabaseSecurityMetadataSource.java

示例8: getFilterSecurityInterceptor

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
/**
 * Gets the filter security interceptor.
 *
 * @return the filter security interceptor
 */
@Bean(name = "fsi")
public FilterSecurityInterceptor getFilterSecurityInterceptor() {
  FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
  interceptor.setAuthenticationManager(getProviderManager());
  interceptor.setAccessDecisionManager(getAffirmativeBased());

  LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();
  requestMap.put(new AntPathRequestMatcher("/adm/**"),
      SecurityConfig.createListFromCommaDelimitedString("ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/adm/restartvm.ajax"), SecurityConfig
      .createListFromCommaDelimitedString("ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/sql/**"), SecurityConfig
      .createListFromCommaDelimitedString("ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/app/**"),
      SecurityConfig.createListFromCommaDelimitedString(
          "ROLE_POWERUSER,ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));
  requestMap.put(new AntPathRequestMatcher("/**"),
      SecurityConfig.createListFromCommaDelimitedString(
          "ROLE_PROBEUSER,ROLE_POWERUSER,ROLE_POWERUSERPLUS,ROLE_MANAGER,ROLE_MANAGER-GUI"));

  interceptor
      .setSecurityMetadataSource(new DefaultFilterInvocationSecurityMetadataSource(requestMap));
  return interceptor;
}
 
開發者ID:psi-probe,項目名稱:psi-probe,代碼行數:30,代碼來源:ProbeSecurityConfig.java

示例9: getAttributesMap

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
/**
 * Get Attributes map from cache if cache set.
 * @return Map
 */
@SuppressWarnings("unchecked")
private Map<RequestMatcher, Collection<ConfigAttribute>> getAttributesMap(){
    
    if(cache!=null){
        Map<RequestMatcher, Collection<ConfigAttribute>> map;
        String key="ex.securityMetadataSource";
        Element e=cache.get(key);
        if(e!=null && !e.isExpired()){
            log.debug("Cache [Hit] ex.securityMetadataSource: {}",e);
            map= (Map<RequestMatcher, Collection<ConfigAttribute>>)e.getObjectValue();
        }else{
            map=processMap();
            Element enew = new Element(key, map);
            cache.put(enew);
            log.debug("Cache [Update] ex.securityMetadataSource: {}",enew);
        }
        return map;
    }
    return processMap();
    
}
 
開發者ID:rockagen,項目名稱:security-stateless-samples,代碼行數:26,代碼來源:ExFilterInvocationSecurityMetadataSource.java

示例10: execute

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
public void execute(FilterSecurityInterceptor filterSecurityInterceptor,
        Map<String, String> resourceMap) {
    Assert.notNull(filterSecurityInterceptor);
    Assert.notNull(resourceMap);

    logger.info("refresh url resource");

    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = null;
    requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();

    for (Map.Entry<String, String> entry : resourceMap.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        requestMap.put(new AntPathRequestMatcher(key),
                SecurityConfig.createListFromCommaDelimitedString(value));
    }

    FilterInvocationSecurityMetadataSource source = new DefaultFilterInvocationSecurityMetadataSource(
            requestMap);
    filterSecurityInterceptor.setSecurityMetadataSource(source);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:22,代碼來源:UrlResourcePopulator.java

示例11: getAttributes

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Override
public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
    FilterInvocation filterInvocation = (FilterInvocation) object;
    for (String url : resourceMap.keySet()) {
        RequestMatcher requestMatcher = new AntPathRequestMatcher(url);
        HttpServletRequest httpRequest = filterInvocation.getHttpRequest();
        if (requestMatcher.matches(httpRequest)) {
            return resourceMap.get(url);
        }
    }
    return null;
}
 
開發者ID:jeikerxiao,項目名稱:SpringBootStudy,代碼行數:13,代碼來源:DemoInvocationSecurityMetadataSourceService.java

示例12: JwtTokenAuthenticationProcessingFilter

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler, 
        TokenExtractor tokenExtractor, RequestMatcher matcher) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
}
 
開發者ID:mjfcolas,項目名稱:infotaf,代碼行數:8,代碼來源:JwtTokenAuthenticationProcessingFilter.java

示例13: SkipPathRequestMatcher

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public SkipPathRequestMatcher(List<String> pathsToSkip, String processingPath) {
       Assert.notNull(pathsToSkip);
       List<RequestMatcher> m = pathsToSkip.stream().map(path -> new AntPathRequestMatcher(path)).collect(Collectors.toList());
       matchers = new OrRequestMatcher(m);
       processingMatcher = new AntPathRequestMatcher(processingPath);
   }
 
開發者ID:mjfcolas,項目名稱:infotaf,代碼行數:8,代碼來源:SkipPathRequestMatcher.java

示例14: JwtTokenAuthenticationProcessingFilter

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler,
    TokenExtractor tokenExtractor, RequestMatcher matcher) {
  super(matcher);
  this.failureHandler = failureHandler;
  this.tokenExtractor = tokenExtractor;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:8,代碼來源:JwtTokenAuthenticationProcessingFilter.java

示例15: SkipPathRequestMatcher

import org.springframework.security.web.util.matcher.RequestMatcher; //導入依賴的package包/類
public SkipPathRequestMatcher(List<String> pathsToSkip, String processingPath) {
  Assert.notNull(pathsToSkip);
  List<RequestMatcher> m = pathsToSkip.stream().map(path -> new AntPathRequestMatcher(path))
      .collect(Collectors.toList());
  matchers = new OrRequestMatcher(m);
  processingMatcher = new AntPathRequestMatcher(processingPath);
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:8,代碼來源:SkipPathRequestMatcher.java


注:本文中的org.springframework.security.web.util.matcher.RequestMatcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。