Package org.springframework.security.config.annotation.web.configurers

# Class PortMapperConfigurer<H extends HttpSecurityBuilder<H>>

java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<PortMapperConfigurer<H>,H>
org.springframework.security.config.annotation.web.configurers.PortMapperConfigurer<H>

All Implemented Interfaces:
  `SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H>`

public final class PortMapperConfigurer<H extends HttpSecurityBuilder<H>> extends AbstractHttpConfigurer<PortMapperConfigurer<H>,H>
Allows configuring a shared `PortMapper` instance used to determine the ports when redirecting between HTTP and HTTPS. The `PortMapper` can be obtained from `AbstractConfiguredSecurityBuilder.getSharedObject(Class)`.

Since:
  3.2

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`final class`
`PortMapperConfigurer.HttpPortMapping`
Allows specifying the HTTPS port for a given HTTP port when redirecting between HTTP and HTTPS.

## Constructor Summary

Constructors
Constructor
Description
`PortMapperConfigurer()`
Creates a new instance

## Method Summary

Modifier and Type
Method
Description
`PortMapperConfigurer<H>.HttpPortMapping`
`http(int httpPort)`
Adds a port mapping
`void`
`init(H http)`
Initialize the `SecurityBuilder`.
`PortMapperConfigurer<H>`
`portMapper(org.springframework.security.web.PortMapper portMapper)`
Allows specifying the `PortMapper` instance.

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

`disable, getSecurityContextHolderStrategy, withObjectPostProcessor, withObjectPostProcessor`

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

`addObjectPostProcessor, addObjectPostProcessor, and, configure, getBuilder, postProcess, setBuilder`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PortMapperConfigurer

public PortMapperConfigurer()
Creates a new instance

## Method Details

### portMapper

public PortMapperConfigurer<H> portMapper(org.springframework.security.web.PortMapper portMapper)
Allows specifying the `PortMapper` instance.

Parameters:
  `portMapper` -
Returns:
  the `PortMapperConfigurer` for further customizations

### http

public PortMapperConfigurer<H>.HttpPortMapping http(int httpPort)
Adds a port mapping

Parameters:
  `httpPort` - the HTTP port that maps to a specific HTTPS port.
Returns:
  `PortMapperConfigurer<H extends HttpSecurityBuilder<H>>.HttpPortMapping` to define the HTTPS port

### init

public void init(H http)
Description copied from interface: `SecurityConfigurer`
Initialize the `SecurityBuilder`. Here only shared state should be created and modified, but not properties on the `SecurityBuilder` used for building the object. This ensures that the `SecurityConfigurer.configure(SecurityBuilder)` method uses the correct shared objects when building. Configurers should be applied here.

Specified by:
  `init` in interface `SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`
Overrides:
  `init` in class `SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`