Class AbstractProfileService<U extends CommonProfile>

All Implemented Interfaces:
Authenticator, ProfileService<U>
Direct Known Subclasses:
InMemoryProfileService

public abstract class AbstractProfileService<U extends CommonProfile> extends ProfileDefinitionAware implements ProfileService<U>, Authenticator
Abstract implementation of the ProfileService for the storage: LDAP, SQL and MongoDB.
Since:
2.0.0
Author:
Jerome Leleu
  • Field Details

    • ID

      public static final String ID
      Constant ID="id"
      See Also:
    • LINKEDID

      public static final String LINKEDID
      Constant LINKEDID="linkedid"
      See Also:
    • SERIALIZED_PROFILE

      public static final String SERIALIZED_PROFILE
      Constant SERIALIZED_PROFILE="serializedprofile"
      See Also:
    • logger

      protected final org.slf4j.Logger logger
    • attributeNames

      protected String[] attributeNames
  • Constructor Details

    • AbstractProfileService

      public AbstractProfileService()
  • Method Details

    • internalInit

      protected void internalInit(boolean forceReinit)
      Internal initialization of the object.
      Specified by:
      internalInit in class InitializableObject
      Parameters:
      forceReinit - a boolean
    • create

      public void create(U profile, String password)
      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)
      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
    • remove

      public void remove(U profile)
      Rmove a profile in the storage.
      Specified by:
      remove in interface ProfileService<U extends CommonProfile>
      Parameters:
      profile - the profile
    • removeById

      public void removeById(String id)
      Remove a profile by its identifier in the storage.
      Specified by:
      removeById in interface ProfileService<U extends CommonProfile>
      Parameters:
      id - the profile identifier
    • 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
    • findById

      public U findById(String id)
      Find a profile by its identifier.
      Specified by:
      findById in interface ProfileService<U extends CommonProfile>
      Parameters:
      id - the identifier
      Returns:
      the found profile
    • findByLinkedId

      public U findByLinkedId(String linkedId)
      Find a profile by its linked identifier.
      Specified by:
      findByLinkedId in interface ProfileService<U extends CommonProfile>
      Parameters:
      linkedId - the linked identifier
      Returns:
      the found profile
    • 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
    • validate

      public Optional<Credentials> validate(CallContext ctx, Credentials cred)
      Validate the credentials. It should throw a CredentialsException in case of failure.
      Specified by:
      validate in interface Authenticator
      Parameters:
      ctx - the context
      cred - the given credentials
      Returns:
      the credentials
    • isLegacyMode

      protected boolean isLegacyMode()

      isLegacyMode.

      Returns:
      a boolean