Class EmbeddedLoginAuthenticationSuccessHandler<P extends PasswordToken,U extends User>
java.lang.Object
com.broadleafcommerce.auth.authorization.security.embedded.login.EmbeddedLoginAuthenticationSuccessHandler<P,U>
- All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationSuccessHandler
public class EmbeddedLoginAuthenticationSuccessHandler<P extends PasswordToken,U extends User>
extends Object
implements org.springframework.security.web.authentication.AuthenticationSuccessHandler
Writes a One-Time Passcode to the response on Embedded Login success.
- Author:
- Nathan Moore (nathandmoore), Cade Rea (cade-rea)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEmbeddedLoginAuthenticationSuccessHandler
(PasscodeService<P, U> passcodeService, UserService<U> userService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.databind.ObjectMapper
protected PasscodeService<P,
U> protected UserService<U>
void
onAuthenticationSuccess
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication) readUser
(jakarta.servlet.http.HttpServletRequest request) Get a user from request parameters.protected void
writeOTPtoResponse
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Create a new passcode and write it to the response.protected void
writeToResponse
(jakarta.servlet.http.HttpServletResponse response, P token) Write a One-Time Passcode wrapped in aEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponse
to the response.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.security.web.authentication.AuthenticationSuccessHandler
onAuthenticationSuccess
-
Field Details
-
ONE_TIME_PASSCODE_PURPOSE
- See Also:
-
-
Constructor Details
-
EmbeddedLoginAuthenticationSuccessHandler
public EmbeddedLoginAuthenticationSuccessHandler(PasscodeService<P, U> passcodeService, UserService<U> userService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
onAuthenticationSuccess
public void onAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication) - Specified by:
onAuthenticationSuccess
in interfaceorg.springframework.security.web.authentication.AuthenticationSuccessHandler
-
writeOTPtoResponse
protected void writeOTPtoResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Create a new passcode and write it to the response.- Parameters:
request
- The HttpServletRequest that is being processed.response
- The HttpServletResponse that will be sent back to the user.
-
readUser
Get a user from request parameters.- Parameters:
request
- HttpServletRequest with "client_id" and "username" parameters.- Returns:
- An Optional with a User that corresponds to the client_id and username from the request.
-
writeToResponse
protected void writeToResponse(jakarta.servlet.http.HttpServletResponse response, P token) throws IOException Write a One-Time Passcode wrapped in aEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponse
to the response.- Parameters:
response
- The HttpServletResponse that will be sent back to the user.token
- ThePasswordToken
to write to the response.- Throws:
IOException
- If there is a problem serializing theEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponse
or writing to the response.
-
getPasscodeService
-
getUserService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-