Class EmbeddedLoginAuthenticationSuccessHandler<P extends PasswordToken,U extends User>
- java.lang.Object
-
- com.broadleafcommerce.auth.user.session.embedded.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
Fields Modifier and Type Field Description static StringONE_TIME_PASSCODE_PURPOSE
-
Constructor Summary
Constructors Constructor Description EmbeddedLoginAuthenticationSuccessHandler(PasscodeService<P,U> passcodeService, UserService<U> userService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()protected PasscodeService<P,U>getPasscodeService()protected UserService<U>getUserService()voidonAuthenticationSuccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication)protected Optional<U>readUser(javax.servlet.http.HttpServletRequest request)Get a user from request parameters.protected voidwriteOTPtoResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Create a new passcode and write it to the response.protected voidwriteToResponse(javax.servlet.http.HttpServletResponse response, P token)Write a One-Time Passcode wrapped in aEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponseto the response.
-
-
-
Field Detail
-
ONE_TIME_PASSCODE_PURPOSE
public static final String ONE_TIME_PASSCODE_PURPOSE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EmbeddedLoginAuthenticationSuccessHandler
public EmbeddedLoginAuthenticationSuccessHandler(PasscodeService<P,U> passcodeService, UserService<U> userService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Detail
-
onAuthenticationSuccess
public void onAuthenticationSuccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication)- Specified by:
onAuthenticationSuccessin interfaceorg.springframework.security.web.authentication.AuthenticationSuccessHandler
-
writeOTPtoResponse
protected void writeOTPtoResponse(javax.servlet.http.HttpServletRequest request, javax.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
protected Optional<U> readUser(javax.servlet.http.HttpServletRequest request)
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(javax.servlet.http.HttpServletResponse response, P token) throws IOExceptionWrite a One-Time Passcode wrapped in aEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponseto the response.- Parameters:
response- The HttpServletResponse that will be sent back to the user.token- ThePasswordTokento write to the response.- Throws:
IOException- If there is a problem serializing theEmbeddedLoginAuthenticationSuccessHandler.EmbeddedLoginOTPResponseor writing to the response.
-
getPasscodeService
protected PasscodeService<P,U> getPasscodeService()
-
getUserService
protected UserService<U> getUserService()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
-