Class OpenSamlAuthenticationTokenConverter
java.lang.Object
org.springframework.security.saml2.provider.service.web.OpenSamlAuthenticationTokenConverter
- All Implemented Interfaces:
AuthenticationConverter
public final class OpenSamlAuthenticationTokenConverter
extends Object
implements AuthenticationConverter
An
AuthenticationConverter
that generates a Saml2AuthenticationToken
appropriate for authenticated a SAML 2.0 Assertion against an
AuthenticationManager
.- Since:
- 6.1
-
Constructor Summary
ConstructorDescriptionConstructs aOpenSamlAuthenticationTokenConverter
given a repository forRelyingPartyRegistration
s -
Method Summary
Modifier and TypeMethodDescriptionconvert
(jakarta.servlet.http.HttpServletRequest request) Resolve an authentication request from the givenHttpServletRequest
.void
setAuthenticationRequestRepository
(Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> authenticationRequestRepository) Use the givenSaml2AuthenticationRequestRepository
to load authentication request.void
setRequestMatcher
(RequestMatcher requestMatcher) Use the givenRequestMatcher
to match the request.
-
Constructor Details
-
OpenSamlAuthenticationTokenConverter
Constructs aOpenSamlAuthenticationTokenConverter
given a repository forRelyingPartyRegistration
s- Parameters:
registrations
- the repository forRelyingPartyRegistration
sRelyingPartyRegistration
s
-
-
Method Details
-
convert
Resolve an authentication request from the givenHttpServletRequest
.First uses the configured
RequestMatcher
to deduce whether an authentication request is being made and optionally for whichregistrationId
.If there is an associated
<saml2:AuthnRequest>
, then theregistrationId
is looked up and used.If a
registrationId
is found in the request, then it is looked up and used. In that case, if none is found aSaml2AuthenticationException
is thrown.Finally, if no
registrationId
is found in the request, then the code attempts to resolve theRelyingPartyRegistration
from the SAML Response's Issuer.- Specified by:
convert
in interfaceAuthenticationConverter
- Parameters:
request
- the HTTP request- Returns:
- the
Saml2AuthenticationToken
authentication request - Throws:
Saml2AuthenticationException
- if theRequestMatcher
specifies a non-existentregistrationId
-
setAuthenticationRequestRepository
public void setAuthenticationRequestRepository(Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> authenticationRequestRepository) Use the givenSaml2AuthenticationRequestRepository
to load authentication request.- Parameters:
authenticationRequestRepository
- theSaml2AuthenticationRequestRepository
to use
-
setRequestMatcher
Use the givenRequestMatcher
to match the request.- Parameters:
requestMatcher
- theRequestMatcher
to use
-