io.undertow.security.impl

## Class FormAuthenticationMechanism

- java.lang.Object
- - io.undertow.security.impl.FormAuthenticationMechanism

All Implemented Interfaces:
  AuthenticationMechanism

    public class FormAuthenticationMechanism
    extends Object
    implements AuthenticationMechanism

Author:
  Stuart Douglas

### Nested Class Summary

### Nested classes/interfaces inherited from interface io.undertow.security.api.AuthenticationMechanism

`AuthenticationMechanism.AuthenticationMechanismOutcome, AuthenticationMechanism.ChallengeResult`

### Field Summary

Fields
`static String` `DEFAULT_POST_LOCATION`
`static String` `LOCATION_ATTRIBUTE`

### Constructor Summary

Constructors
Constructor and Description
`FormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage)`
`FormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, IdentityManager identityManager)`
`FormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, String postLocation)`
`FormAuthenticationMechanism(FormParserFactory formParserFactory, String name, String loginPage, String errorPage, String postLocation, IdentityManager identityManager)`
`FormAuthenticationMechanism(String name, String loginPage, String errorPage)`
`FormAuthenticationMechanism(String name, String loginPage, String errorPage, String postLocation)`

### Method Summary

All Methods Instance Methods Concrete Methods
`AuthenticationMechanism.AuthenticationMechanismOutcome` `authenticate(HttpServerExchange exchange, SecurityContext securityContext)` Perform authentication of the request.
`protected void` `handleRedirectBack(HttpServerExchange exchange)`
`AuthenticationMechanism.AuthenticationMechanismOutcome` `runFormAuth(HttpServerExchange exchange, SecurityContext securityContext)`
`AuthenticationMechanism.ChallengeResult` `sendChallenge(HttpServerExchange exchange, SecurityContext securityContext)` Send an authentication challenge to the remote client.
`protected Integer` `servePage(HttpServerExchange exchange, String location)`
`protected void` `storeInitialLocation(HttpServerExchange exchange)`

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

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

### Field Detail

#### LOCATION_ATTRIBUTE

    public static final String LOCATION_ATTRIBUTE

#### DEFAULT_POST_LOCATION

    public static final String DEFAULT_POST_LOCATION

See Also:
  Constant Field Values

### Constructor Detail

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(String name,
                                       String loginPage,
                                       String errorPage)

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(String name,
                                       String loginPage,
                                       String errorPage,
                                       String postLocation)

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(FormParserFactory formParserFactory,
                                       String name,
                                       String loginPage,
                                       String errorPage)

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(FormParserFactory formParserFactory,
                                       String name,
                                       String loginPage,
                                       String errorPage,
                                       IdentityManager identityManager)

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(FormParserFactory formParserFactory,
                                       String name,
                                       String loginPage,
                                       String errorPage,
                                       String postLocation)

#### FormAuthenticationMechanism

    public FormAuthenticationMechanism(FormParserFactory formParserFactory,
                                       String name,
                                       String loginPage,
                                       String errorPage,
                                       String postLocation,
                                       IdentityManager identityManager)

### Method Detail

#### authenticate

    public AuthenticationMechanism.AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange,
                                                                               SecurityContext securityContext)

Description copied from interface: `AuthenticationMechanism`
Perform authentication of the request. Any potentially blocking work should be performed in the handoff executor provided

Specified by:
  `authenticate` in interface `AuthenticationMechanism`
Parameters:
  `exchange` - The exchange
Returns:

#### runFormAuth

    public AuthenticationMechanism.AuthenticationMechanismOutcome runFormAuth(HttpServerExchange exchange,
                                                                              SecurityContext securityContext)

#### handleRedirectBack

    protected void handleRedirectBack(HttpServerExchange exchange)

#### sendChallenge

    public AuthenticationMechanism.ChallengeResult sendChallenge(HttpServerExchange exchange,
                                                                 SecurityContext securityContext)

Description copied from interface: `AuthenticationMechanism`
Send an authentication challenge to the remote client.

The individual mechanisms should update the response headers and body of the message as appropriate however they should not set the response code, instead that should be indicated in the `AuthenticationMechanism.ChallengeResult` and the most appropriate overall response code will be selected. This method should not return `null`.

Specified by:
  `sendChallenge` in interface `AuthenticationMechanism`
Parameters:
  `exchange` - The exchange
  `securityContext` - The security context
Returns:
  A `AuthenticationMechanism.ChallengeResult` indicating if a challenge was sent and the desired response code.

#### storeInitialLocation

    protected void storeInitialLocation(HttpServerExchange exchange)

#### servePage

    protected Integer servePage(HttpServerExchange exchange,
                                String location)