Class MongoProfileService

java.lang.Object
org.pac4j.core.util.InitializableObject
org.pac4j.core.profile.definition.ProfileDefinitionAware
org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
org.pac4j.mongo.profile.service.MongoProfileService
All Implemented Interfaces:
org.pac4j.core.credentials.authenticator.Authenticator, org.pac4j.core.profile.service.ProfileService<MongoProfile>

public class MongoProfileService extends org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
The MongoDB profile service (which supersedes the Mongo authenticator).
Since:
2.0.0
Author:
Jerome Leleu
  • Field Summary

    Fields inherited from class org.pac4j.core.profile.service.AbstractProfileService

    attributeNames, ID, LINKEDID, logger, SERIALIZED_PROFILE

    Fields inherited from interface org.pac4j.core.credentials.authenticator.Authenticator

    ALWAYS_VALIDATE, NEVER_VALIDATE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for MongoProfileService.
    MongoProfileService(com.mongodb.client.MongoClient mongoClient)
    Constructor for MongoProfileService.
    MongoProfileService(com.mongodb.client.MongoClient mongoClient, String attributes)
    Constructor for MongoProfileService.
    MongoProfileService(com.mongodb.client.MongoClient mongoClient, String attributes, org.pac4j.core.credentials.password.PasswordEncoder passwordEncoder)
    Constructor for MongoProfileService.
    MongoProfileService(com.mongodb.client.MongoClient mongoClient, org.pac4j.core.credentials.password.PasswordEncoder passwordEncoder)
    Constructor for MongoProfileService.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    protected com.mongodb.client.MongoCollection<org.bson.Document>
    getCollection.
    protected void
    insert(Map<String,Object> attributes)
    protected void
    internalInit(boolean forceReinit)
    protected List<Map<String,Object>>
    read(List<String> names, String key, String value)
    protected void
    update(Map<String,Object> attributes)

    Methods inherited from class org.pac4j.core.profile.service.AbstractProfileService

    convertAttributesToProfile, convertProfileAndPasswordToAttributes, create, defineAttributesToRead, findById, findByLinkedId, getAttributes, getIdAttribute, getPasswordAttribute, getPasswordEncoder, getSerializer, getUsernameAttribute, isLegacyMode, remove, removeById, setAttributes, setIdAttribute, setPasswordAttribute, setPasswordEncoder, setSerializer, setUsernameAttribute, update, validate

    Methods inherited from class org.pac4j.core.profile.definition.ProfileDefinitionAware

    getProfileDefinition, setProfileDefinition, setProfileDefinitionIfUndefined

    Methods inherited from class org.pac4j.core.util.InitializableObject

    afterInternalInit, beforeInternalInit, getInitialized, getLastAttempt, getMaxAttempts, getMinTimeIntervalBetweenAttemptsInMilliseconds, getNbAttempts, init, init, isInitialized, reinit, setMaxAttempts, setMinTimeIntervalBetweenAttemptsInMilliseconds, shouldInitialize, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MongoProfileService

      public MongoProfileService()

      Constructor for MongoProfileService.

    • MongoProfileService

      public MongoProfileService(com.mongodb.client.MongoClient mongoClient)

      Constructor for MongoProfileService.

      Parameters:
      mongoClient - a MongoClient object
    • MongoProfileService

      public MongoProfileService(com.mongodb.client.MongoClient mongoClient, String attributes)

      Constructor for MongoProfileService.

      Parameters:
      mongoClient - a MongoClient object
      attributes - a String object
    • MongoProfileService

      public MongoProfileService(com.mongodb.client.MongoClient mongoClient, String attributes, org.pac4j.core.credentials.password.PasswordEncoder passwordEncoder)

      Constructor for MongoProfileService.

      Parameters:
      mongoClient - a MongoClient object
      attributes - a String object
      passwordEncoder - a PasswordEncoder object
    • MongoProfileService

      public MongoProfileService(com.mongodb.client.MongoClient mongoClient, org.pac4j.core.credentials.password.PasswordEncoder passwordEncoder)

      Constructor for MongoProfileService.

      Parameters:
      mongoClient - a MongoClient object
      passwordEncoder - a PasswordEncoder object
  • Method Details

    • internalInit

      protected void internalInit(boolean forceReinit)
      Overrides:
      internalInit in class org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
    • insert

      protected void insert(Map<String,Object> attributes)
      Specified by:
      insert in class org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
    • update

      protected void update(Map<String,Object> attributes)
      Specified by:
      update in class org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
    • deleteById

      protected void deleteById(String id)
      Specified by:
      deleteById in class org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
    • read

      protected List<Map<String,Object>> read(List<String> names, String key, String value)
      Specified by:
      read in class org.pac4j.core.profile.service.AbstractProfileService<MongoProfile>
    • getCollection

      protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection()

      getCollection.

      Returns:
      a MongoCollection object