Class DefaultConsentService
java.lang.Object
com.hybris.yprofile.consent.services.DefaultConsentService
- All Implemented Interfaces:
ConsentService
Implementation for
ConsentService. Service is responsible to generate and provide the consent reference.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteConsentReferenceInConsentServiceAndInConsentModel(ConsentModel consentModel, String baseSiteId) Deletes the consent reference when the user revokes the consent for profile or user closes the accountprotected ConsentServiceClientFetches the consent reference from the active consent model.getConsentReferenceFromCookie(String siteId, javax.servlet.http.HttpServletRequest request) Fetches the consent reference from cookiegetConsentReferenceFromHeader(javax.servlet.http.HttpServletRequest request) Fetches the consent reference from header name specified in the property profileservices.occ.consent.header.nameFetches the consent reference from sessionprotected EnhancedCookieGeneratorprotected Optional<BaseSiteModel>protected static StringgetDebugFlagValue(UserModel userModel) protected Stringprotected booleanbooleanMethod checks for consents stored in the session - in the same way for both anonymous and logged in user.booleanisProfileTrackingConsentGiven(javax.servlet.http.HttpServletRequest request) Checks if the user (logged In or Anonymous) has granted the consent to allow profile trackingprotected booleanisProfileTrackingConsentGivenForAnonymousUser(javax.servlet.http.HttpServletRequest request) protected booleanprotected booleanisProfileTrackingConsentGivenInCookieForAnonymousUser(javax.servlet.http.Cookie anonymousConsentCookie) protected booleanisProfileTrackingConsentGivenInHeaderForAnonymousUser(String anonymousConsentHeader) protected booleanprotected static booleanisValidConsentReference(String consentReferenceId) protected static voidprotected static voidlogSuccess(Optional<com.hybris.charon.RawResponse> rawResponse, String message) protected booleanvoidremoves the consent reference in sessionprotected voidresetConsentReferenceInConsentModel(ConsentModel consentModel) voidsaveConsentReferenceInSession(String consentId) It gets the consent reference stored in a cookie and saves it in the session for further eventsvoidsaveConsentReferenceInSessionAndConsentModel(javax.servlet.http.HttpServletRequest request) It gets the consent reference stored in a cookie (generated by ProfileTag) and saves it in the session and in the user model (for logged In users) for further eventsprotected voidsetAttributeInSession(String key, Object value) voidsetBaseSiteService(BaseSiteService baseSiteService) voidsetCommerceConsentService(CommerceConsentService commerceConsentService) voidsetConfigurationService(ConfigurationService configurationService) protected voidsetConsentReferenceInConsentModel(String consentReferenceId) voidsetCookieGenerator(EnhancedCookieGenerator cookieGenerator) voidsetModelService(ModelService modelService) voidsetProfileConfigurationService(ProfileConfigurationService profileConfigurationService) voidsetProfileConsent(boolean consent) voidsetProfileConsentCookieAndSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean consent) Saves the profile consent separately in a cookie and session attributevoidsetProfileIdCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String consentReferenceId) Saves the profile id i.e old consent reference separately as a session cookie so that profile tag can skip getting a new consent reference.voidsetRetrieveRestClientStrategy(RetrieveRestClientStrategy retrieveRestClientStrategy) voidsetSessionService(SessionService sessionService) voidsetUserService(UserService userService) protected booleanshouldSendEvent(String consentReference, String baseSiteId)
-
Field Details
-
PROFILE_CONSENT_GIVEN_COOKIE_NAME_SUFFIX
- See Also:
-
-
Constructor Details
-
DefaultConsentService
public DefaultConsentService()
-
-
Method Details
-
isProfileTrackingConsentGiven
public boolean isProfileTrackingConsentGiven(javax.servlet.http.HttpServletRequest request) Description copied from interface:ConsentServiceChecks if the user (logged In or Anonymous) has granted the consent to allow profile tracking- Specified by:
isProfileTrackingConsentGivenin interfaceConsentService- Parameters:
request- the http request- Returns:
- true or false
-
isProfileTrackingConsentGivenForLoggedInUser
protected boolean isProfileTrackingConsentGivenForLoggedInUser() -
profileTrackingConsentForLoggedInUser
-
isAnonymousUser
protected boolean isAnonymousUser() -
isUserSoftLoggedIn
protected boolean isUserSoftLoggedIn() -
isProfileTrackingConsentGivenForAnonymousUser
protected boolean isProfileTrackingConsentGivenForAnonymousUser(javax.servlet.http.HttpServletRequest request) -
isProfileTrackingConsentGivenInCookieForAnonymousUser
protected boolean isProfileTrackingConsentGivenInCookieForAnonymousUser(javax.servlet.http.Cookie anonymousConsentCookie) -
isProfileTrackingConsentGivenInHeaderForAnonymousUser
protected boolean isProfileTrackingConsentGivenInHeaderForAnonymousUser(String anonymousConsentHeader) -
saveConsentReferenceInSessionAndConsentModel
public void saveConsentReferenceInSessionAndConsentModel(javax.servlet.http.HttpServletRequest request) Description copied from interface:ConsentServiceIt gets the consent reference stored in a cookie (generated by ProfileTag) and saves it in the session and in the user model (for logged In users) for further events- Specified by:
saveConsentReferenceInSessionAndConsentModelin interfaceConsentService- Parameters:
request- Http request
-
getConsentReferenceFromCookie
public String getConsentReferenceFromCookie(String siteId, javax.servlet.http.HttpServletRequest request) Description copied from interface:ConsentServiceFetches the consent reference from cookie- Specified by:
getConsentReferenceFromCookiein interfaceConsentService- Parameters:
siteId- base site identifierrequest- http request- Returns:
- consent reference
-
getConsentReferenceFromHeader
Description copied from interface:ConsentServiceFetches the consent reference from header name specified in the property profileservices.occ.consent.header.name- Specified by:
getConsentReferenceFromHeaderin interfaceConsentService- Parameters:
request- http request- Returns:
- consent reference
-
getConsentReferenceFromSession
Description copied from interface:ConsentServiceFetches the consent reference from session- Specified by:
getConsentReferenceFromSessionin interfaceConsentService- Returns:
- consent reference
-
getConsentReferenceFromConsentModel
Description copied from interface:ConsentServiceFetches the consent reference from the active consent model.- Specified by:
getConsentReferenceFromConsentModelin interfaceConsentService- Returns:
- consent reference
-
setProfileConsentCookieAndSession
public void setProfileConsentCookieAndSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean consent) Description copied from interface:ConsentServiceSaves the profile consent separately in a cookie and session attribute- Specified by:
setProfileConsentCookieAndSessionin interfaceConsentService- Parameters:
request- http requestresponse- http reponseconsent- true or false
-
setProfileConsent
public void setProfileConsent(boolean consent) - Specified by:
setProfileConsentin interfaceConsentService
-
removeConsentReferenceInSession
public void removeConsentReferenceInSession()Description copied from interface:ConsentServiceremoves the consent reference in session- Specified by:
removeConsentReferenceInSessionin interfaceConsentService
-
deleteConsentReferenceInConsentServiceAndInConsentModel
public void deleteConsentReferenceInConsentServiceAndInConsentModel(ConsentModel consentModel, String baseSiteId) Description copied from interface:ConsentServiceDeletes the consent reference when the user revokes the consent for profile or user closes the account- Specified by:
deleteConsentReferenceInConsentServiceAndInConsentModelin interfaceConsentService- Parameters:
consentModel- the userbaseSiteId- the base site id
-
saveConsentReferenceInSession
Description copied from interface:ConsentServiceIt gets the consent reference stored in a cookie and saves it in the session for further events- Specified by:
saveConsentReferenceInSessionin interfaceConsentService- Parameters:
consentId- the consent reference
-
isProfileTrackingConsentGiven
public boolean isProfileTrackingConsentGiven()Method checks for consents stored in the session - in the same way for both anonymous and logged in user. Consents must be already stored in the session.- Specified by:
isProfileTrackingConsentGivenin interfaceConsentService- Returns:
- true if consent is given
-
getDebugFlagValue
-
shouldSendEvent
-
isValidConsentReference
-
setAttributeInSession
-
getSiteId
-
getCurrentBaseSiteModel
-
logSuccess
-
logError
-
getClient
-
getCookieGenerator
-
setCookieGenerator
-
getSessionService
-
setSessionService
-
getUserService
-
setUserService
-
getProfileConfigurationService
-
setProfileConfigurationService
-
getRetrieveRestClientStrategy
-
setRetrieveRestClientStrategy
-
getBaseSiteService
-
setBaseSiteService
-
getModelService
-
setModelService
-
getConfigurationService
-
setConfigurationService
-
getCommerceConsentService
-
setCommerceConsentService
-
setConsentReferenceInConsentModel
-
resetConsentReferenceInConsentModel
-
setProfileIdCookie
public void setProfileIdCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String consentReferenceId) Description copied from interface:ConsentServiceSaves the profile id i.e old consent reference separately as a session cookie so that profile tag can skip getting a new consent reference.- Specified by:
setProfileIdCookiein interfaceConsentService- Parameters:
request- http requestresponse- http response to which the cookie is added if the request doesnt have CR cookieconsentReferenceId- the profile id or consent reference id of the user
-