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


Java HttpSecurity.addFilter方法代碼示例

本文整理匯總了Java中org.springframework.security.config.annotation.web.builders.HttpSecurity.addFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpSecurity.addFilter方法的具體用法?Java HttpSecurity.addFilter怎麽用?Java HttpSecurity.addFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.config.annotation.web.builders.HttpSecurity的用法示例。


在下文中一共展示了HttpSecurity.addFilter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.springframework.security.config.annotation.web.builders.HttpSecurity; //導入方法依賴的package包/類
@Override
protected void configure(HttpSecurity http) throws Exception {

    http = http.addFilter(new WebAsyncManagerIntegrationFilter());
    http = http.addFilterBefore(jwtAuthFilter(), UsernamePasswordAuthenticationFilter.class);

    http
            .antMatcher("/ext/**")
            .csrf().requireCsrfProtectionMatcher(csrfSecurityRequestMatcher).and()
            .headers().frameOptions().sameOrigin().and()
            .authorizeRequests()
            .antMatchers("/ext/stream/**", "/ext/coverArt*", "/ext/share/**", "/ext/hls/**")
            .hasAnyRole("TEMP", "USER").and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
            .exceptionHandling().and()
            .securityContext().and()
            .requestCache().and()
            .anonymous().and()
            .servletApi();
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:21,代碼來源:GlobalSecurityConfig.java

示例2: configure

import org.springframework.security.config.annotation.web.builders.HttpSecurity; //導入方法依賴的package包/類
/**
 * Configure spring security to enable a simple webform-login + a simple rest login.
 */
@Override
public void configure(HttpSecurity http) throws Exception {

  super.configure(http);
  // usage of addFilter is sufficient for BasicAuthenticationFilter.class. The filter will be added according to the
  // order defined in:
  // http://docs.spring.io/autorepo/docs/spring-security/4.1.0.RC1/apidocs/org/springframework/security/config/annotation/web/builders/HttpSecurity.html#addFilter-javax.servlet.Filter-
  http.addFilter(basicAuthenticationFilter());

  // Use the following to disable csrf in tests
  http.csrf().disable();

  LOG.debug("used non static class");
}
 
開發者ID:oasp,項目名稱:oasp-tutorial-sources,代碼行數:18,代碼來源:TestWebSecurityConfig.java


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