当前位置: 首页>>代码示例>>Java>>正文


Java DelegatingRequestMatcherHeaderWriter类代码示例

本文整理汇总了Java中org.springframework.security.web.header.writers.DelegatingRequestMatcherHeaderWriter的典型用法代码示例。如果您正苦于以下问题:Java DelegatingRequestMatcherHeaderWriter类的具体用法?Java DelegatingRequestMatcherHeaderWriter怎么用?Java DelegatingRequestMatcherHeaderWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DelegatingRequestMatcherHeaderWriter类属于org.springframework.security.web.header.writers包,在下文中一共展示了DelegatingRequestMatcherHeaderWriter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.springframework.security.web.header.writers.DelegatingRequestMatcherHeaderWriter; //导入依赖的package包/类
/** {@inheritDoc} */
    @Override
    protected void configure(HttpSecurity httpSecurity) throws Exception {
        
        RequestMatcher matcher = new AntPathRequestMatcher("/login");
        DelegatingRequestMatcherHeaderWriter headerWriter =
            new DelegatingRequestMatcherHeaderWriter(matcher,new XFrameOptionsHeaderWriter());

        //to disable loading application back button after logout
        httpSecurity
            .headers()
                .defaultsDisabled()
                    .cacheControl().and()
                .contentTypeOptions().and().addHeaderWriter(headerWriter)
                .httpStrictTransportSecurity()
                    .includeSubDomains(true)
                    .maxAgeInSeconds(31536000).and()
                .frameOptions().sameOrigin().xssProtection().block(false);
        
//        httpSecurity.requestCache().requestCache(new NullRequestCache());
        
        httpSecurity
            /*.csrf()
                .disable()*/
            .authorizeRequests()
                .expressionHandler(webExpressionHandler())
                .antMatchers("/forgotPwd", "/resetPwd*", "/successRegister*",
                        "/invalidSession.html", "/registrationConfirm*",
                        "/registration.html", "/user/registration", "/login*")
                .permitAll()
                // .antMatchers(HttpMethod.POST,"/api","/api/**").hasRole("ROLE_ADMIN")
                .anyRequest().fullyAuthenticated()
                .and()
            .formLogin()
                .loginPage("/login.html")
                .defaultSuccessUrl("/home.html")
                .usernameParameter("username")
                .passwordParameter("password")
                .failureUrl("/login.html?error=true")
                // .successHandler(myAuthenticationSuccessHandler)
//                .failureHandler(authenticationFailureHandler)
                .permitAll()
                .and()
            .sessionManagement()
                .invalidSessionUrl("/invalidSession.html")
                .sessionFixation().none()
                .and()
            .logout()
                .logoutUrl("/logout")
                .logoutSuccessUrl("/login.html")
                .invalidateHttpSession(true)
                .deleteCookies("remember-me", "SESSION")
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                .permitAll()
                .and()
            .rememberMe()
                .rememberMeServices(rememberMeServices())
                .tokenValiditySeconds(86400)
                .rememberMeCookieName("remember-me")
                .and()
            .exceptionHandling().accessDeniedPage("/403");
    }
 
开发者ID:rajadilipkolli,项目名称:springsecuredthymeleafapp,代码行数:63,代码来源:SecurityConfiguration.java


注:本文中的org.springframework.security.web.header.writers.DelegatingRequestMatcherHeaderWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。