Class NativeRoleMappingStore

java.lang.Object
org.elasticsearch.xpack.security.authc.support.mapper.NativeRoleMappingStore
All Implemented Interfaces:
org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper

public class NativeRoleMappingStore extends Object implements org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper
This store reads + writes role mappings in an Elasticsearch index.
The store is responsible for all read and write operations as well as resolving roles.

No caching is done by this class, it is handled at a higher level and no polling for changes is done by this class. Modification operations make a best effort attempt to clear the cache on all nodes for the user that was modified.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper

    org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper.DistinguishedNamePredicate, org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper.UserData
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeRoleMappingStore(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.client.internal.Client client, SecurityIndexManager securityIndex, org.elasticsearch.script.ScriptService scriptService)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping
    buildMapping(String id, org.elasticsearch.common.bytes.BytesReference source)
     
    void
    deleteRoleMapping(org.elasticsearch.xpack.core.security.action.rolemapping.DeleteRoleMappingRequest request, org.elasticsearch.action.ActionListener<Boolean> listener)
    Deletes a named mapping from the index
    void
    getRoleMappings(Set<String> names, org.elasticsearch.action.ActionListener<List<org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping>> listener)
    Retrieves one or more mappings from the index.
    protected void
    loadMappings(org.elasticsearch.action.ActionListener<List<org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping>> listener)
    Loads all mappings from the index.
    void
     
    void
    putRoleMapping(org.elasticsearch.xpack.core.security.action.rolemapping.PutRoleMappingRequest request, org.elasticsearch.action.ActionListener<Boolean> listener)
    Stores (create or update) a single mapping in the index
    void
    refreshRealmOnChange(org.elasticsearch.xpack.core.security.authc.support.CachingRealm realm)
    Indicates that the provided realm should have its cache cleared if this store is updated (that is, putRoleMapping(PutRoleMappingRequest, ActionListener) or deleteRoleMapping(DeleteRoleMappingRequest, ActionListener) are called).
    void
    resolveRoles(org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper.UserData user, org.elasticsearch.action.ActionListener<Set<String>> listener)
     
    void
    usageStats(org.elasticsearch.action.ActionListener<Map<String,Object>> listener)
    Provides usage statistics for this store.

    Methods inherited from class java.lang.Object

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

    • NativeRoleMappingStore

      public NativeRoleMappingStore(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.client.internal.Client client, SecurityIndexManager securityIndex, org.elasticsearch.script.ScriptService scriptService)
  • Method Details

    • loadMappings

      protected void loadMappings(org.elasticsearch.action.ActionListener<List<org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping>> listener)
      Loads all mappings from the index. package private for unit testing
    • buildMapping

      protected org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping buildMapping(String id, org.elasticsearch.common.bytes.BytesReference source)
    • putRoleMapping

      public void putRoleMapping(org.elasticsearch.xpack.core.security.action.rolemapping.PutRoleMappingRequest request, org.elasticsearch.action.ActionListener<Boolean> listener)
      Stores (create or update) a single mapping in the index
    • deleteRoleMapping

      public void deleteRoleMapping(org.elasticsearch.xpack.core.security.action.rolemapping.DeleteRoleMappingRequest request, org.elasticsearch.action.ActionListener<Boolean> listener)
      Deletes a named mapping from the index
    • getRoleMappings

      public void getRoleMappings(Set<String> names, org.elasticsearch.action.ActionListener<List<org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping>> listener)
      Retrieves one or more mappings from the index. If names is null or empty, then this retrieves all mappings. Otherwise it retrieves the specified mappings by name.
    • usageStats

      public void usageStats(org.elasticsearch.action.ActionListener<Map<String,Object>> listener)
      Provides usage statistics for this store. The resulting map contains the keys
      • size - The total number of mappings stored in the index
      • enabled - The number of mappings that are enabled
    • onSecurityIndexStateChange

      public void onSecurityIndexStateChange(SecurityIndexManager.State previousState, SecurityIndexManager.State currentState)
    • resolveRoles

      public void resolveRoles(org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper.UserData user, org.elasticsearch.action.ActionListener<Set<String>> listener)
      Specified by:
      resolveRoles in interface org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper
    • refreshRealmOnChange

      public void refreshRealmOnChange(org.elasticsearch.xpack.core.security.authc.support.CachingRealm realm)
      Indicates that the provided realm should have its cache cleared if this store is updated (that is, putRoleMapping(PutRoleMappingRequest, ActionListener) or deleteRoleMapping(DeleteRoleMappingRequest, ActionListener) are called).
      Specified by:
      refreshRealmOnChange in interface org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper
      See Also:
      • ClearRealmCacheAction