Class DefaultConsentService
- java.lang.Object
-
- com.hybris.yprofile.consent.services.DefaultConsentService
-
- All Implemented Interfaces:
ConsentService
public class DefaultConsentService extends java.lang.Object implements ConsentService
Implementation forConsentService. Service is responsible to generate and provide the consent reference.
-
-
Constructor Summary
Constructors Constructor Description DefaultConsentService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteConsentReferenceInConsentServiceAndInUserModel(UserModel userModel, java.lang.String baseSiteId)Deletes the consent reference when the user revokes the consent for profile or user closes the accountBaseSiteServicegetBaseSiteService()protected ConsentServiceClientgetClient()java.lang.StringgetConsentReferenceFromCookie(java.lang.String siteId, javax.servlet.http.HttpServletRequest request)Fetches the consent reference from cookiejava.lang.StringgetConsentReferenceFromSession()Fetches the consent reference from sessionprotected EnhancedCookieGeneratorgetCookieGenerator()protected java.util.Optional<BaseSiteModel>getCurrentBaseSiteModel()protected static java.lang.StringgetDebugFlagValue(UserModel userModel)ModelServicegetModelService()ProfileConfigurationServicegetProfileConfigurationService()RetrieveRestClientStrategygetRetrieveRestClientStrategy()SessionServicegetSessionService()protected java.lang.StringgetSiteId()UserServicegetUserService()protected booleanisAnonymousUser()booleanisProfileTrackingConsentGiven()Method 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(java.util.Optional<javax.servlet.http.Cookie> anonymousConsentCookie)protected booleanisProfileTrackingConsentGivenForLoggedInUser()protected booleanisUserSoftLoggedIn()protected static booleanisValidConsentReference(java.lang.String consentReferenceId)protected static voidlogError(java.lang.Throwable error)protected static voidlogSuccess(java.util.Optional<com.hybris.charon.RawResponse> rawResponse, java.lang.String message)protected booleanprofileTrackingConsentForLoggedInUser(java.lang.String consent)voidremoveConsentReferenceCookieAndSession(javax.servlet.http.HttpServletResponse response)removes the consent reference cookieprotected voidresetConsentReferenceForUser(UserModel user)voidsaveConsentReferenceInSession(java.lang.String consentId)It gets the consent reference stored in a cookie and saves it in the session for further eventsvoidsaveConsentReferenceInSessionAndCurrentUserModel(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(java.lang.String key, java.lang.Object value)voidsetBaseSiteService(BaseSiteService baseSiteService)protected voidsetConsentReferenceForCurrentUser(java.lang.String consentReferenceId)voidsetCookieGenerator(EnhancedCookieGenerator cookieGenerator)voidsetModelService(ModelService modelService)voidsetProfileConfigurationService(ProfileConfigurationService profileConfigurationService)voidsetProfileConsentCookieAndSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean consent)Saves the profile consent separately in a cookie and session attributevoidsetRetrieveRestClientStrategy(RetrieveRestClientStrategy retrieveRestClientStrategy)voidsetSessionService(SessionService sessionService)voidsetUserService(UserService userService)protected booleanshouldSendEvent(java.lang.String consentReference, java.lang.String baseSiteId)
-
-
-
Method Detail
-
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
protected boolean profileTrackingConsentForLoggedInUser(java.lang.String consent)
-
isAnonymousUser
protected boolean isAnonymousUser()
-
isUserSoftLoggedIn
protected boolean isUserSoftLoggedIn()
-
isProfileTrackingConsentGivenForAnonymousUser
protected boolean isProfileTrackingConsentGivenForAnonymousUser(java.util.Optional<javax.servlet.http.Cookie> anonymousConsentCookie)
-
saveConsentReferenceInSessionAndCurrentUserModel
public void saveConsentReferenceInSessionAndCurrentUserModel(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:
saveConsentReferenceInSessionAndCurrentUserModelin interfaceConsentService- Parameters:
request- Http request
-
getConsentReferenceFromCookie
public java.lang.String getConsentReferenceFromCookie(java.lang.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
-
getConsentReferenceFromSession
public java.lang.String getConsentReferenceFromSession()
Description copied from interface:ConsentServiceFetches the consent reference from session- Specified by:
getConsentReferenceFromSessionin 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
-
removeConsentReferenceCookieAndSession
public void removeConsentReferenceCookieAndSession(javax.servlet.http.HttpServletResponse response)
Description copied from interface:ConsentServiceremoves the consent reference cookie- Specified by:
removeConsentReferenceCookieAndSessionin interfaceConsentService- Parameters:
response- http response
-
deleteConsentReferenceInConsentServiceAndInUserModel
public void deleteConsentReferenceInConsentServiceAndInUserModel(UserModel userModel, java.lang.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:
deleteConsentReferenceInConsentServiceAndInUserModelin interfaceConsentService- Parameters:
userModel- the userbaseSiteId- the base site id
-
saveConsentReferenceInSession
public void saveConsentReferenceInSession(java.lang.String consentId)
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
-
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
protected static java.lang.String getDebugFlagValue(UserModel userModel)
-
shouldSendEvent
protected boolean shouldSendEvent(java.lang.String consentReference, java.lang.String baseSiteId)
-
isValidConsentReference
protected static boolean isValidConsentReference(java.lang.String consentReferenceId)
-
setAttributeInSession
protected void setAttributeInSession(java.lang.String key, java.lang.Object value)
-
getSiteId
protected java.lang.String getSiteId()
-
getCurrentBaseSiteModel
protected java.util.Optional<BaseSiteModel> getCurrentBaseSiteModel()
-
logSuccess
protected static void logSuccess(java.util.Optional<com.hybris.charon.RawResponse> rawResponse, java.lang.String message)
-
logError
protected static void logError(java.lang.Throwable error)
-
getClient
protected ConsentServiceClient getClient()
-
getCookieGenerator
protected EnhancedCookieGenerator getCookieGenerator()
-
setCookieGenerator
public void setCookieGenerator(EnhancedCookieGenerator cookieGenerator)
-
getSessionService
public SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getUserService
public UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getProfileConfigurationService
public ProfileConfigurationService getProfileConfigurationService()
-
setProfileConfigurationService
public void setProfileConfigurationService(ProfileConfigurationService profileConfigurationService)
-
getRetrieveRestClientStrategy
public RetrieveRestClientStrategy getRetrieveRestClientStrategy()
-
setRetrieveRestClientStrategy
public void setRetrieveRestClientStrategy(RetrieveRestClientStrategy retrieveRestClientStrategy)
-
getBaseSiteService
public BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getModelService
public ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
setConsentReferenceForCurrentUser
protected void setConsentReferenceForCurrentUser(java.lang.String consentReferenceId)
-
resetConsentReferenceForUser
protected void resetConsentReferenceForUser(UserModel user)
-
-