本文整理汇总了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");
}