Package org.springframework.security.web.authentication.preauth.j2ee

# Class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource

java.lang.Object
org.springframework.security.web.authentication.preauth.j2ee.J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource

All Implemented Interfaces:
  `org.springframework.beans.factory.InitializingBean`, `org.springframework.security.authentication.AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest,PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>`

public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends Object implements org.springframework.security.authentication.AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest,PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>, org.springframework.beans.factory.InitializingBean
Implementation of AuthenticationDetailsSource which converts the user's J2EE roles (as obtained by calling `HttpServletRequest.isUserInRole(String)`) into `GrantedAuthority`s and stores these in the authentication details object.

Since:
  2.0

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Set<String>`
`j2eeMappableRoles`
The role attributes returned by the configured `MappableAttributesRetriever`
`protected org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper`
`j2eeUserRoles2GrantedAuthoritiesMapper`
`protected final org.apache.commons.logging.Log`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
Check that all required properties have been set.
`PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails`
`buildDetails(jakarta.servlet.http.HttpServletRequest context)`
Builds the authentication details object.
`protected Collection<String>`
`getUserRoles(jakarta.servlet.http.HttpServletRequest request)`
Obtains the list of user roles based on the current user's JEE roles.
`void`
`setMappableRolesRetriever(org.springframework.security.core.authority.mapping.MappableAttributesRetriever aJ2eeMappableRolesRetriever)`
`void`
`setUserRoles2GrantedAuthoritiesMapper(org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper mapper)`

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

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

## Field Details

### logger

protected final org.apache.commons.logging.Log logger

### j2eeMappableRoles

protected Set<String> j2eeMappableRoles
The role attributes returned by the configured `MappableAttributesRetriever`

### j2eeUserRoles2GrantedAuthoritiesMapper

protected org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper j2eeUserRoles2GrantedAuthoritiesMapper

## Constructor Details

### J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource

public J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource()

## Method Details

### afterPropertiesSet

public void afterPropertiesSet()
Check that all required properties have been set.

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`

### getUserRoles

protected Collection<String> getUserRoles(jakarta.servlet.http.HttpServletRequest request)
Obtains the list of user roles based on the current user's JEE roles. The `HttpServletRequest.isUserInRole(String)` method is called for each of the values in the `j2eeMappableRoles` set to determine if that role should be assigned to the user.

Parameters:
  `request` - the request which should be used to extract the user's roles.
Returns:
  The subset of `j2eeMappableRoles` which applies to the current user making the request.

### buildDetails

public PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails buildDetails(jakarta.servlet.http.HttpServletRequest context)
Builds the authentication details object.

Specified by:
  `buildDetails` in interface `org.springframework.security.authentication.AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest,PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>`
See Also:
  - `AuthenticationDetailsSource.buildDetails(Object)`

### setMappableRolesRetriever

public void setMappableRolesRetriever(org.springframework.security.core.authority.mapping.MappableAttributesRetriever aJ2eeMappableRolesRetriever)

Parameters:
  `aJ2eeMappableRolesRetriever` - The MappableAttributesRetriever to use

### setUserRoles2GrantedAuthoritiesMapper

public void setUserRoles2GrantedAuthoritiesMapper(org.springframework.security.core.authority.mapping.Attributes2GrantedAuthoritiesMapper mapper)

Parameters:
  `mapper` - The Attributes2GrantedAuthoritiesMapper to use