Class Ltpa2Configurer
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, org.springframework.security.config.annotation.web.builders.HttpSecurity>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<Ltpa2Configurer, org.springframework.security.config.annotation.web.builders.HttpSecurity>
de.sephirothj.spring.security.ltpa2.Ltpa2Configurer
- All Implemented Interfaces:
org.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, org.springframework.security.config.annotation.web.builders.HttpSecurity>
public class Ltpa2Configurer
extends org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<Ltpa2Configurer, org.springframework.security.config.annotation.web.builders.HttpSecurity>
A convenient way to configure the pre-authentication filter.
How to use:
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http) throws Exception
{
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.antMatchers("/hello").hasRole("DEVELOPERS")
.and()
.apply(new Ltpa2Configurer())
.sharedKey(sharedKey())
.signerKey(signerKey())
;
http.userDetailsService(userDetailsService());
}
}
A UserDetailsService is required! In case no instance is exposed, you have to provide one using AuthenticationManagerBuilder#userDetailsService.
- Author:
- Sephiroth
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder) cookieName(@NonNull String cookieName) configures the name of the cookie expected to contain the LTPA2 tokenheaderName(@NonNull String headerName) configures the name of the header expected to contain the LTPA2 tokenMethods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, getRequestMatcherBuilder, getSecurityContextHolderStrategy, withObjectPostProcessorMethods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, getBuilder, init, postProcess, setBuilder
-
Constructor Details
-
Ltpa2Configurer
public Ltpa2Configurer()
-
-
Method Details
-
configure
public void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder) - Specified by:
configurein interfaceorg.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, org.springframework.security.config.annotation.web.builders.HttpSecurity>- Overrides:
configurein classorg.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, org.springframework.security.config.annotation.web.builders.HttpSecurity>
-
cookieName
configures the name of the cookie expected to contain the LTPA2 token- Parameters:
cookieName- the cookie name- Returns:
- this instance
- Throws:
IllegalArgumentException- ifcookieNameis empty
-
headerName
configures the name of the header expected to contain the LTPA2 token- Parameters:
headerName- the name of the header- Returns:
- this instance
- Throws:
IllegalArgumentException- ifheaderNameis empty
-