Class Ltpa2Configurer

java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B>
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    configure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder)
     
    cookieName(String cookieName)
    configures the name of the cookie expected to contain the LTPA2 token
    headerName(String headerName)
    configures the name of the header expected to contain the LTPA2 token

    Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer

    disable, getSecurityContextHolderStrategy, withObjectPostProcessor

    Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter

    addObjectPostProcessor, and, getBuilder, init, postProcess, setBuilder

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Ltpa2Configurer

      public Ltpa2Configurer()
  • Method Details

    • configure

      public void configure(org.springframework.security.config.annotation.web.builders.HttpSecurity builder) throws Exception
      Specified by:
      configure in interface org.springframework.security.config.annotation.SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Overrides:
      configure in class org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,org.springframework.security.config.annotation.web.builders.HttpSecurity>
      Throws:
      Exception
    • cookieName

      public Ltpa2Configurer cookieName(@NonNull String cookieName)
      configures the name of the cookie expected to contain the LTPA2 token
      Parameters:
      cookieName - the cookie name
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if cookieName is empty
    • headerName

      public Ltpa2Configurer headerName(@NonNull String 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 - if headerName is empty