Class AbstractProfileService<U extends CommonProfile>

    • Constructor Detail

      • AbstractProfileService

        public AbstractProfileService()
    • Method Detail

      • create

        public void create​(U profile,
                           String password)
        Description copied from interface: ProfileService
        Create a profile with the associated password in the storage.
        Specified by:
        create in interface ProfileService<U extends CommonProfile>
        Parameters:
        profile - the profile
        password - the password
      • update

        public void update​(U profile,
                           String password)
        Description copied from interface: ProfileService
        Update a profile (with the associated password) in the storage.
        Specified by:
        update in interface ProfileService<U extends CommonProfile>
        Parameters:
        profile - the profile
        password - the optional password
      • convertProfileAndPasswordToAttributes

        protected Map<String,​Object> convertProfileAndPasswordToAttributes​(U profile,
                                                                                 String password)
        Convert a profile and a password into a map of attributes for the storage.
        Parameters:
        profile - the profile
        password - the password
        Returns:
        the attributes
      • insert

        protected abstract void insert​(Map<String,​Object> attributes)
        Insert the attributes in the storage.
        Parameters:
        attributes - the attributes
      • update

        protected abstract void update​(Map<String,​Object> attributes)
        Update the attributes in the storage.
        Parameters:
        attributes - the attributes
      • deleteById

        protected abstract void deleteById​(String id)
        Delete a profile by its identifier in the storage.
        Parameters:
        id - the identifier
      • defineAttributesToRead

        protected List<String> defineAttributesToRead()
        Define the attributes to read in the storage.
        Returns:
        the attributes
      • convertAttributesToProfile

        protected U convertAttributesToProfile​(List<Map<String,​Object>> listStorageAttributes,
                                               String username)
        Convert the list of map of attributes from the storage into a profile.
        Parameters:
        listStorageAttributes - the list of map of attributes
        username - the username used for login
        Returns:
        the profile
      • read

        protected abstract List<Map<String,​Object>> read​(List<String> names,
                                                               String key,
                                                               String value)
        Read the list of defined attributes in the storage for key=value query.
        Parameters:
        names - the attribute names to read
        key - the key for the query
        value - the value for the query
        Returns:
        the list of map of attributes
      • isLegacyMode

        protected boolean isLegacyMode()
      • setPasswordEncoder

        public void setPasswordEncoder​(PasswordEncoder passwordEncoder)
      • getAttributes

        public String getAttributes()
      • setAttributes

        public void setAttributes​(String attributes)

        Since version 2.0 of pac4j, the profile can be saved, updated and deleted in the storage by serializing the profile (in the serializedprofile attribute).

        In addition to what existed in previous versions, the profile was built from existing attributes. Setting this attribute with a list of attributes separated by commas (no aliasing) allows you to use different attributes of the storage instead of the serializedprofile attribute.

        Parameters:
        attributes - the attributes
      • setJavaSerializationHelper

        public void setJavaSerializationHelper​(JavaSerializationHelper javaSerializationHelper)
      • getUsernameAttribute

        public String getUsernameAttribute()
      • setUsernameAttribute

        public void setUsernameAttribute​(String usernameAttribute)
      • getPasswordAttribute

        public String getPasswordAttribute()
      • setPasswordAttribute

        public void setPasswordAttribute​(String passwordAttribute)
      • getIdAttribute

        public String getIdAttribute()
      • setIdAttribute

        public void setIdAttribute​(String idAttribute)