Class DefaultConsentService

  • All Implemented Interfaces:
    ConsentService

    public class DefaultConsentService
    extends java.lang.Object
    implements ConsentService
    Implementation for ConsentService. Service is responsible to generate and provide the consent reference.
    • Constructor Detail

      • DefaultConsentService

        public DefaultConsentService()
    • Method Detail

      • isProfileTrackingConsentGiven

        public boolean isProfileTrackingConsentGiven​(javax.servlet.http.HttpServletRequest request)
        Description copied from interface: ConsentService
        Checks if the user (logged In or Anonymous) has granted the consent to allow profile tracking
        Specified by:
        isProfileTrackingConsentGiven in interface ConsentService
        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: ConsentService
        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 events
        Specified by:
        saveConsentReferenceInSessionAndCurrentUserModel in interface ConsentService
        Parameters:
        request - Http request
      • getConsentReferenceFromCookie

        public java.lang.String getConsentReferenceFromCookie​(java.lang.String siteId,
                                                              javax.servlet.http.HttpServletRequest request)
        Description copied from interface: ConsentService
        Fetches the consent reference from cookie
        Specified by:
        getConsentReferenceFromCookie in interface ConsentService
        Parameters:
        siteId - base site identifier
        request - http request
        Returns:
        consent reference
      • setProfileConsentCookieAndSession

        public void setProfileConsentCookieAndSession​(javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response,
                                                      boolean consent)
        Description copied from interface: ConsentService
        Saves the profile consent separately in a cookie and session attribute
        Specified by:
        setProfileConsentCookieAndSession in interface ConsentService
        Parameters:
        request - http request
        response - http reponse
        consent - true or false
      • removeConsentReferenceCookieAndSession

        public void removeConsentReferenceCookieAndSession​(javax.servlet.http.HttpServletResponse response)
        Description copied from interface: ConsentService
        removes the consent reference cookie
        Specified by:
        removeConsentReferenceCookieAndSession in interface ConsentService
        Parameters:
        response - http response
      • deleteConsentReferenceInConsentServiceAndInUserModel

        public void deleteConsentReferenceInConsentServiceAndInUserModel​(UserModel userModel,
                                                                         java.lang.String baseSiteId)
        Description copied from interface: ConsentService
        Deletes the consent reference when the user revokes the consent for profile or user closes the account
        Specified by:
        deleteConsentReferenceInConsentServiceAndInUserModel in interface ConsentService
        Parameters:
        userModel - the user
        baseSiteId - the base site id
      • saveConsentReferenceInSession

        public void saveConsentReferenceInSession​(java.lang.String consentId)
        Description copied from interface: ConsentService
        It gets the consent reference stored in a cookie and saves it in the session for further events
        Specified by:
        saveConsentReferenceInSession in interface ConsentService
      • 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:
        isProfileTrackingConsentGiven in interface ConsentService
        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)
      • setSessionService

        public void setSessionService​(SessionService sessionService)
      • setUserService

        public void setUserService​(UserService userService)
      • setProfileConfigurationService

        public void setProfileConfigurationService​(ProfileConfigurationService profileConfigurationService)
      • setRetrieveRestClientStrategy

        public void setRetrieveRestClientStrategy​(RetrieveRestClientStrategy retrieveRestClientStrategy)
      • setBaseSiteService

        public void setBaseSiteService​(BaseSiteService baseSiteService)
      • setModelService

        public void setModelService​(ModelService modelService)
      • setConsentReferenceForCurrentUser

        protected void setConsentReferenceForCurrentUser​(java.lang.String consentReferenceId)
      • resetConsentReferenceForUser

        protected void resetConsentReferenceForUser​(UserModel user)