Class StaleStateProtectionServiceImpl
java.lang.Object
org.broadleafcommerce.common.security.service.StaleStateProtectionServiceImpl
- All Implemented Interfaces:
StaleStateProtectionService
@Service("blStaleStateProtectionService")
public class StaleStateProtectionServiceImpl
extends Object
implements StaleStateProtectionService
- Author:
- jfischer
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompareToken(String passedToken) Compare the state version token provided by the request to what is resident in the user session.Retrieve the state version token resident in the user's session, or create one if it doesn't exist.Retrieve the parameter key used to harvest the state version token value from the requestvoidRemove the current state version token in the user's session, if exists.voidinvalidateState(boolean notify) Remove the current state version token in the user's session, if exists.booleanWhether or not the protection provided by this service is active.booleansendRedirectOnStateChange(jakarta.servlet.http.HttpServletResponse response, String... stateChangeParams) Utility method to send a redirect for the current url with state change params cleared.
-
Field Details
-
STATEVERSIONTOKEN
- See Also:
-
STATECHANGENOTIFICATIONTOKEN
- See Also:
-
STATEVERSIONTOKENPARAMETER
- See Also:
-
staleStateProtectionEnabled
@Value("${stale.state.protection.enabled:false}") protected boolean staleStateProtectionEnabled
-
-
Constructor Details
-
StaleStateProtectionServiceImpl
public StaleStateProtectionServiceImpl()
-
-
Method Details
-
compareToken
Description copied from interface:StaleStateProtectionServiceCompare the state version token provided by the request to what is resident in the user session. If the tokens are not equal, the determination is made that the request is coming from a stale page and aStaleStateServiceExceptionis emitted.- Specified by:
compareTokenin interfaceStaleStateProtectionService- Parameters:
passedToken- the state version token from the request
-
getStateVersionToken
Description copied from interface:StaleStateProtectionServiceRetrieve the state version token resident in the user's session, or create one if it doesn't exist.- Specified by:
getStateVersionTokenin interfaceStaleStateProtectionService- Returns:
-
invalidateState
public void invalidateState()Description copied from interface:StaleStateProtectionServiceRemove the current state version token in the user's session, if exists. This usually occurs in response to a key state change.- Specified by:
invalidateStatein interfaceStaleStateProtectionService
-
invalidateState
public void invalidateState(boolean notify) Description copied from interface:StaleStateProtectionServiceRemove the current state version token in the user's session, if exists. This usually occurs in response to a key state change.- Specified by:
invalidateStatein interfaceStaleStateProtectionService- Parameters:
notify- Whether or not the request should be notified that state was invalidated. SeeStaleStateProtectionService.sendRedirectOnStateChange(HttpServletResponse, String...).
-
sendRedirectOnStateChange
public boolean sendRedirectOnStateChange(jakarta.servlet.http.HttpServletResponse response, String... stateChangeParams) throws IOException Description copied from interface:StaleStateProtectionServiceUtility method to send a redirect for the current url with state change params cleared. State change params are request url parameters that drive primary context change. For example, url parameters for sandbox, catalog and profile changes are considered state change params. When such a param is utilized, the state token is reset to represent the fundamental context change and is stored in session. However, it is now desirable to redirect the user to the target url without the state change params to avoid a subsequent check.- Specified by:
sendRedirectOnStateChangein interfaceStaleStateProtectionService- Parameters:
response- the current http responsestateChangeParams- any request parameter names being used by the system to drive state change- Returns:
- whether or not a redirect was sent based on detection of an earlier call to
StaleStateProtectionService.invalidateState() - Throws:
IOException
-
isEnabled
public boolean isEnabled()Description copied from interface:StaleStateProtectionServiceWhether or not the protection provided by this service is active.- Specified by:
isEnabledin interfaceStaleStateProtectionService- Returns:
-
getStateVersionTokenParameter
Description copied from interface:StaleStateProtectionServiceRetrieve the parameter key used to harvest the state version token value from the request- Specified by:
getStateVersionTokenParameterin interfaceStaleStateProtectionService- Returns:
-