Class ByteBufferBackedVendorConsent

  • All Implemented Interfaces:
    VendorConsent

    public class ByteBufferBackedVendorConsent
    extends Object
    implements VendorConsent
    Implementation of VendorConsent. This implementation uses byte buffer (wrapped with Bits) as a storage of consent string values and parses individual fields on demand. This should work well in environment where vendor consent string is decoded, couple of isPurposeAllowed()/isVendorAllowed() calls are made and then value of the consent is discarded. In the environment where decoded consent string is kept for longer time with numerous isPurposeAllowed()/isVendorAllowed() calls a different implementation may be needed that would cache results of those calls.
    • Constructor Detail

      • ByteBufferBackedVendorConsent

        public ByteBufferBackedVendorConsent​(Bits bits)
    • Method Detail

      • getVersion

        public int getVersion()
        Specified by:
        getVersion in interface VendorConsent
        Returns:
        the version of consent string format
      • getCmpId

        public int getCmpId()
        Specified by:
        getCmpId in interface VendorConsent
        Returns:
        the Consent Manager Provider ID that last updated the consent string
      • getCmpVersion

        public int getCmpVersion()
        Specified by:
        getCmpVersion in interface VendorConsent
        Returns:
        the Consent Manager Provider version
      • getConsentScreen

        public int getConsentScreen()
        Specified by:
        getConsentScreen in interface VendorConsent
        Returns:
        the screen number in the CMP where consent was given
      • getConsentLanguage

        public String getConsentLanguage()
        Specified by:
        getConsentLanguage in interface VendorConsent
        Returns:
        the two-letter ISO639-1 language code that CMP asked for consent in
      • getVendorListVersion

        public int getVendorListVersion()
        Specified by:
        getVendorListVersion in interface VendorConsent
        Returns:
        version of vendor list used in most recent consent string update.
      • getAllowedPurposeIds

        public Set<Integer> getAllowedPurposeIds()
        Specified by:
        getAllowedPurposeIds in interface VendorConsent
        Returns:
        the set of purpose id's which are permitted according to this consent string
      • getAllowedPurposes

        public Set<Purpose> getAllowedPurposes()
        Specified by:
        getAllowedPurposes in interface VendorConsent
        Returns:
        the set of allowed purposes which are permitted according to this consent string
      • getAllowedPurposesBits

        public int getAllowedPurposesBits()
        Specified by:
        getAllowedPurposesBits in interface VendorConsent
        Returns:
        an integer equivalent of allowed purpose id bits according to this consent string
      • getAllowedVendorIds

        public Set<Integer> getAllowedVendorIds()
        Specified by:
        getAllowedVendorIds in interface VendorConsent
        Returns:
        the set of allowed vendor id's which are permitted according to this consent string
      • getMaxVendorId

        public int getMaxVendorId()
        Specified by:
        getMaxVendorId in interface VendorConsent
        Returns:
        the maximum VendorId for which consent values are given.
      • isPurposeAllowed

        public boolean isPurposeAllowed​(int purposeId)
        Description copied from interface: VendorConsent
        Check whether purpose with specified ID is allowed
        Specified by:
        isPurposeAllowed in interface VendorConsent
        Parameters:
        purposeId - purpose ID
        Returns:
        true if purpose is allowed in this consent, false otherwise
      • isPurposeAllowed

        public boolean isPurposeAllowed​(Purpose purpose)
        Description copied from interface: VendorConsent
        Check whether specified purpose is allowed
        Specified by:
        isPurposeAllowed in interface VendorConsent
        Parameters:
        purpose - purpose to check
        Returns:
        true if purpose is allowed in this consent, false otherwise
      • isVendorAllowed

        public boolean isVendorAllowed​(int vendorId)
        Description copied from interface: VendorConsent
        Check whether vendor with specified ID is allowd
        Specified by:
        isVendorAllowed in interface VendorConsent
        Parameters:
        vendorId - vendor ID
        Returns:
        a boolean describing if a user has consented to a particular vendor
      • toByteArray

        public byte[] toByteArray()
        Specified by:
        toByteArray in interface VendorConsent
        Returns:
        the value of this consent as byte array
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object