Java 类org.springframework.security.web.util.matcher.NegatedRequestMatcher 实例源码

项目:jhipster-registry    文件:OAuth2SsoConfiguration.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .csrf().disable()
        .requestMatcher(new NegatedRequestMatcher(authorizationHeaderRequestMatcher))
        .httpBasic()
        .realmName("JHipster Registry")
    .and()
        .authorizeRequests()
        .antMatchers("/services/**").authenticated()
        .antMatchers("/eureka/**").hasAuthority(AuthoritiesConstants.ADMIN)
        .antMatchers("/api/profile-info").permitAll()
        .antMatchers("/api/**").authenticated()
        .antMatchers("/config/**").hasAuthority(AuthoritiesConstants.ADMIN)
        .antMatchers("/management/health").permitAll()
        .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
        .anyRequest().permitAll();
}
项目:generator-jhipster    文件:_OAuth2SsoConfiguration.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .csrf()
        .disable()
        .addFilterBefore(corsFilter, CsrfFilter.class)
        .headers()
        .frameOptions()
        .disable()
    .and()
        .logout()
        .logoutUrl("/api/logout")
        .logoutSuccessHandler(ajaxLogoutSuccessHandler())
    .and()
        .requestMatcher(new NegatedRequestMatcher(authorizationHeaderRequestMatcher))
        .authorizeRequests()
        .antMatchers("/api/profile-info").permitAll()
        .antMatchers("/api/**").authenticated()
        .antMatchers("/management/health").permitAll()
        .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
        .anyRequest().permitAll();
}
项目:oma-riista-web    文件:CsrfCookieGeneratorFilter.java   
public CsrfCookieGeneratorFilter(final String... ignoredPatterns) {
    if (ignoredPatterns.length > 0) {
        this.ignoredMatcher = new OrRequestMatcher(Arrays.stream(ignoredPatterns)
                .map(AntPathRequestMatcher::new)
                .collect(toList()));
    } else {
        this.ignoredMatcher = new NegatedRequestMatcher(AnyRequestMatcher.INSTANCE);
    }
}
项目:spring-custom-token-auth    文件:WebSecurityConfig.java   
protected AbstractAuthenticationProcessingFilter createCustomFilter() throws Exception {
    //here we define the interfaces which don't need any authorisation
    AuthFilter filter = new AuthFilter(new NegatedRequestMatcher(
      new AndRequestMatcher(
         new AntPathRequestMatcher("/login"),
         new AntPathRequestMatcher("/health")
      )
    ));
    filter.setAuthenticationManager(authenticationManagerBean());
    return filter;
}
项目:spring-security-saml-dsl    文件:SAMLConfigurer.java   
@Override
public void init(HttpSecurity http) {

    metadataProvider = identityProvider.metadataProvider();
    ExtendedMetadata extendedMetadata = extendedMetadata(identityProvider.discoveryEnabled);
    extendedMetadataDelegate = extendedMetadataDelegate(extendedMetadata);
    serviceProvider.keyManager = serviceProvider.keyManager();
    cachingMetadataManager = cachingMetadataManager();
    webSSOProfile = new WebSSOProfileImpl(samlProcessor, cachingMetadataManager);
    samlAuthenticationProvider = samlAuthenticationProvider(webSSOProfileConsumer);

    bootstrap();

    SAMLContextProvider contextProvider = contextProvider();
    SAMLEntryPoint samlEntryPoint = samlEntryPoint(contextProvider);

    try {
        http
            .httpBasic()
            .authenticationEntryPoint(samlEntryPoint);

        CsrfConfigurer<HttpSecurity> csrfConfigurer = http.getConfigurer(CsrfConfigurer.class);
        if(csrfConfigurer != null) {
            // Workaround to get working with Spring Security 3.2.
            RequestMatcher ignored = new AntPathRequestMatcher("/saml/SSO");
            RequestMatcher notIgnored = new NegatedRequestMatcher(ignored);
            RequestMatcher matcher = new AndRequestMatcher(new DefaultRequiresCsrfMatcher(), notIgnored);

            csrfConfigurer.requireCsrfProtectionMatcher(matcher);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    http
        .addFilterBefore(metadataGeneratorFilter(samlEntryPoint, extendedMetadata), ChannelProcessingFilter.class)
        .addFilterAfter(samlFilter(samlEntryPoint, contextProvider), BasicAuthenticationFilter.class)
        .authenticationProvider(samlAuthenticationProvider);
}
项目:iris    文件:SecurityConfig.java   
@Bean
@Autowired
public DelegatingAuthenticationEntryPoint delegatingAuthenticationEntryPoint(BasicAuthenticationEntryPoint basic,
    LoginUrlAuthenticationEntryPoint login) {

    LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
    entryPoints.put(new RequestHeaderRequestMatcher("Content-Type", "application/json"), basic);
    entryPoints.put(new NegatedRequestMatcher(new RequestContainingAcceptTextHeaderRequestMatcher()), basic);

    DelegatingAuthenticationEntryPoint delegate = new DelegatingAuthenticationEntryPoint(entryPoints);
    delegate.setDefaultEntryPoint(login);

    return delegate;
}
项目:moserp    文件:TestSecurityConfiguration.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    NegatedRequestMatcher matcher = new NegatedRequestMatcher(new AntPathRequestMatcher("/login", "POST"));
    http.csrf().disable().authorizeRequests().requestMatchers(matcher).authenticated().and().httpBasic();
}